2011-10-04 45 views
0

我有一個jQuery模態窗口一個問題,從更新面板內的按鈕被稱爲..jQuery UI的對話與更新面板ASP按鍵觸發

這裏的見解..

的Javascript用於開啓在aspx頁面jQuery的模態對話框..

<script type='text/javascript'> 
    function openModalDiv(divname) { 
     $('#' + divname).dialog({ 
      autoOpen: false, 
      bgiframe: true, 
      closeOnEscape: true, 
      modal: true, 
      resizable: false, 
      height: 'auto', 
      buttons: { Ok: function() { closeModalDiv(divname) } }, 
      open: function (event, ui) { jQuery('.ui-dialog-titlebar-close').hide(); } 
     }); 
     $('#' + divname).dialog('open'); 
     ('#' + divname).parent().appendTo($('form:FrmSearch')); 
     $('#' + divname).css('overflow', 'hidden') 
    } 

    function closeModalDiv(divname) { 
     $('#' + divname).dialog('close'); 
    } 
</script> 

在aspx頁面..按鈕

<asp:UpdatePanel ID="upDialogs" runat="server"> 
    <ContentTemplate> 
     <asp:Button ID="btnOpenDialog" runat="server" Text="Open Dialog" onclick="btnOpenDialog_Click" /> 
    </ContentTemplate> 
</asp:UpdatePanel> 

這需要從通過JavaScript代碼隱藏調用的股利..

<div id="ErrorDiv2" title="Error" style="visibility:hidden"> 
    <p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>Please select an option among the results and try again!</p> 
</div> 

最後後面的代碼..

protected void btnOpenDialog_Click(object sender, EventArgs e) 
{ 
    if (ProfileID == null) 
    { 
     Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorDivOpen", "document.getElementById('ErrorDiv2').style.visibility = 'visible';", true); 
     Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorDivShow", "openModalDiv('ErrorDiv2');", true); 
    } 
} 

現在詳細問題.. 沒有更新面板中的模態對話框持久性有機污染物很不錯,但充分後回..

我想只有部分回發,因此正在使用更新面板..

以下是我試過的解決方案..

  1. 將更新面板添加到現有的div,dint工作。
  2. 添加RUNAT =「服務器」沿着股利,仍然力工作的最新面板..

任何一個可以幫助我與可能的解決方案?

回答

2

感謝您的快速回復,但我找到了另一種解決方案。

我在Div中添加了更新面板和runat參數。

<asp:UpdatePanel ID="upErrorDiv" runat="server"><ContentTemplate> 
    <div runat="server" id="ErrorDiv2" title="Error" style="visibility:hidden"> 
     <p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>Please select an option among the results and try again!</p> 
    </div> 
</ContentTemplate></asp:UpdatePanel> 

更改後面的代碼爲。

if (ProfileID == null) 
{ 
    ScriptManager.RegisterStartupScript(ErrorDiv2,this.GetType(), "ErrorDivOpen", "document.getElementById('ErrorDiv2').style.visibility = 'visible';", true); 
    ScriptManager.RegisterStartupScript(ErrorDiv2,this.GetType(), "ErrorDivShow", "openModalDiv('ErrorDiv2');", true); 
    return; 
} 
0

你可以嘗試在UpdatePanel中注入JavaScript到Literal控件中,是否註冊到ClientScriptManager?

克里斯