ASP.NET onclientclick C#
我有一个带有 onclientclick js 函数的 ImageButton:
deleteButton = new ImageButton();
deleteButton.ID = "deleteRiskButton" + planRisk.Id;
deleteButton.ImageUrl = "../../Images/deleteButton.gif";
deleteButton.Click += new ImageClickEventHandler(deleteButton_Click);
deleteButton.OnClientClick = "removeRowAfterDeletion('" + deleteButton.ID + "')";
在这个 JavaScript 函数中,我有一个对话框,确保用户打算删除有问题的项目。
function removeRowAfterDeletion(buttonId)
{
var deleteConfirmationDialog = confirm("Are you sure you want to remove this risk from your plan?.")
return deleteConfirmationDialog;
}
我的印象是,如果 onclientclick 函数返回 false,则不会发生回发。但是,即使我单击取消,deleteButton_Click c# 函数也会被调用。
知道问题是什么吗?
I have an ImageButton with an onclientclick js function attached:
deleteButton = new ImageButton();
deleteButton.ID = "deleteRiskButton" + planRisk.Id;
deleteButton.ImageUrl = "../../Images/deleteButton.gif";
deleteButton.Click += new ImageClickEventHandler(deleteButton_Click);
deleteButton.OnClientClick = "removeRowAfterDeletion('" + deleteButton.ID + "')";
Inside this JavaScript function i have a dialog making sure the user intended to delete the item in question.
function removeRowAfterDeletion(buttonId)
{
var deleteConfirmationDialog = confirm("Are you sure you want to remove this risk from your plan?.")
return deleteConfirmationDialog;
}
I was under the impression that if the onclientclick function returns false then the postback would not occur. However, even if the I click cancel the deleteButton_Click c# function is called.
Any idea what the problem is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
try this:
试试这个。
Try this.