根据 jquery 对话框结果调用 asp:button 的 OnClick
我有一个带有适当 OnClick 的 asp:button 。我还有一个 jQuery UI 对话框,单击该按钮时会打开该对话框。我希望当用户在对话框中单击“是”时调用 OnClick 函数。如果“是”调用一个代码隐藏函数,“否”调用另一个代码隐藏函数,那就更好了。但对于我的一生,我无法弄清楚如何。
这是我当前的代码:
$(function() {
$("#dialog:ui-dialog").dialog("destroy");
$("#dialog-confirm").dialog({
autoOpen:false,
resizable:false,
height:175,
width: 450,
modal:true,
buttons: {
"Yes": function() {
$(this).dialog("close");
},
"No": function() {
$(this).dialog("close");
}
}
});
$(".navigation").click(function(e) {
e.preventDefault();
$("#dialog-confirm").dialog('open');
});
});
和按钮:
<asp:Button ID="testerE" class="navigation" runat="server" OnClick="JustATest" Text="Test me" />
I have an asp:button with appropriate OnClick. I also have a jQuery UI dialog that opens when said button is clicked. I would like the OnClick function to be called when the user clicks "Yes" in the dialog. Even better would be if one codebehind function was called for "Yes" and another for "No." But for the life of me I can't figure out how.
Here's my current code:
$(function() {
$("#dialog:ui-dialog").dialog("destroy");
$("#dialog-confirm").dialog({
autoOpen:false,
resizable:false,
height:175,
width: 450,
modal:true,
buttons: {
"Yes": function() {
$(this).dialog("close");
},
"No": function() {
$(this).dialog("close");
}
}
});
$(".navigation").click(function(e) {
e.preventDefault();
$("#dialog-confirm").dialog('open');
});
});
and the button:
<asp:Button ID="testerE" class="navigation" runat="server" OnClick="JustATest" Text="Test me" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不将这些按钮放在 div 中并将其用作模式对话框中显示的 html?
否则,您需要调用页面上存在的 __doPostBack 函数。
Why don't you put those buttons inside a div and use that as the html that is displayed in the modal dialog?
Otherwise, you would need to call the
__doPostBack
function that is present on the page.