2010-09-03 50 views
1

我在Asp.net应用程序中遇到问题。 当我尝试保存一些数据时,我检查数据是否正确,何时不调用带有错误消息的jquery对话框。但是当我的jquery对话框出现时,我的背景形式消失了。 和我得到一个JavaScript错误:“HTML解析错误无法修改父元素关闭前的父容器元素”。当scriptmanager调用jquery对话框时,页面消失

这是在代码隐藏我的jQuery的对话框电话:

string script = "openDialog('" + text + "', '" + title + "');"; 
    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "open", script, true); 

这是我的母版我的jQuery的对话框:

function openDialog(text, title) { 
    var $dialog = $('<div></div>') 
    .html(text) 
    .dialog({ 
     autoOpen: false, 
     title: title, 
     modal: true, 
     height: 100, 
     width: 220, 
     buttons: { 
      Ok: function() { 
       $(this).dialog('close'); 
      }    
     }, 
     open: function(event, ui){ 
      $('body').css('overflow','hidden'); 
     }   
    }); 

    $dialog.dialog('open'); 
} 

我有一些网页,我有相同的代码,有它的工作原理?

回答

1

根据这link它可能是因为你正在尝试添加新的div是在页面完成呈现之前添加的。试试这个:

string script = "jQuery(document).ready(function($) { openDialog('" + text + "', '" + title + "'); })"; 
+0

THX!现在正在工作。 – Ben 2010-09-03 08:39:27

4

WOW!我刚刚意识到对话框的标记位于<form>标记内,将其移出并正在工作。看起来像VS扩展<form>时,我添加了一些东西,也抓住了我的东西。

<div id="dialog-form" title="Fill Here"> 

<fieldset> 

    <textarea rows="10" id="myPaste" cols="50"></textarea> 

</fieldset> 
</div> 
<button id="create-user">Click Here</button> 

      <asp:Button ID="btnSend" runat="server" Text="Send ALL" 
       onclick="btnSend_Click" Width="127px" /> 
</form> 

将其改为:

<asp:Button ID="btnSend" runat="server" Text="Send ALL" 
      onclick="btnSend_Click" Width="127px" /> 
</form>  

<div id="dialog-form" title="Fill Here"> 

<fieldset> 

    <textarea rows="10" id="myPaste" cols="50"></textarea> 

</fieldset> 
</div> 

<button id="create-user">Click Here</button> 
相关问题