2010-09-03 45 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> 
相關問題