无法在jquery对话框中单击asp.net按钮

我已经在线搜索过,并尝试了一些解决方案,但没有一个能为我工作。

我在div中有一个按钮。 我在jquery对话框中显示div。 按钮单击在jquery对话框中不起作用。

我的代码如下:

ASPX

Configure Alerts

jQuery的

 function ViewModelPopup2() { $("#ViewModalPopupDiv2").dialog({ scrollable: true, width: 800, modal: true }); } 

aspx.cs

 protected void btnSendAlertEmail_Click(object sender, EventArgs e) { // Code to send email } protected void btnConfigureAlerts_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript (this, this.GetType(), "callScriptFunction", "ViewModelPopup2();", true); } } 

请让我知道我需要做什么,以触发服务器控制事件。

我也遇到过asp.net按钮和jQuery UI Dialog这个问题。 要解决此问题,您需要在aspnet按钮中将标签UseSubmitBehaviorfalse

如果UseSubmitBehavior属性设置为true (这是默认值),该按钮将使用浏览器的提交机制(并且jQuery Dialog UI正在操作它),如果UseSubmitBehavior设置为false ,该按钮将使用客户端脚本asp.net框架包含在页面中发布到表单。

所以你的HTML应该是这样的:

 
Configure Alerts

更多详细信息,请访问http://msdn.microsoft.com/library/system.web.ui.webcontrols.button.usesubmitbehavior.aspx

这是经典,感谢移动我的对话框jQuery,问题。

jQuery UI由于某种原因将对话框代码移动到表单标记之外的html标记的底部。 您需要使用更多jQuery将对话框移回到表单中:

dlg.parent().appendTo(jQuery('form:first'));

其中dlg是你的jQuery.UI对话框对象。

  var dlg = $("#ViewModalPopupDiv2").dialog({ scrollable: true, width: 800, modal: true }); dlg.parent().appendTo(jQuery('form:first')); 

这应该让事情再次为你效劳。 干杯!

如果这不起作用,请尝试在open事件中执行此操作:

open: function(type,data) { $(this).parent().appendTo("form"); }