从codebehind打开jQuery Dialog

所以我必须从代​​码隐藏中显示一个jquery UI对话框.
我已经尝试了一切: this,this,this,并且还更改了这些答案以测试它是否适用于我但不起作用.
我正在使用第一个解决方案,因为它是有组织的.如果我使用alert(‘whatever’)而不是我的jquery对话框代码,它可以工作.所以我知道它的工作,但对话没有任何反应.我也尝试过用彩盒,也没用.

有人可以给我一个解决方法吗?这将是apreciated.
谢谢.

我的aspx:

HEAD
<script type="text/javascript">

    function BindEvents() {
        $.fx.speeds._default = 1000;
        $(document).ready(function () {                
            var dlg = $("#DivMostrarIguales").dialog({
                autoOpen: false,show: "fold",hide: "clip",width: 500,height: 500
            });
            dlg.parent().appendTo(jQuery("form:first"));
        });
    }

</script>
ENDHEAD
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:UpdatePanel runat="server" ID="upTotal">
    <ContentTemplate>
        <script type="text/javascript">
            Sys.Application.add_load(BindEvents);                
        </script>....
 <tr>
          <td class="Izquierda">
                (*) Número único:
          </td>
          <td class="Derecha">
             <asp:TextBox ID="tbNumeroUnico" runat="server"></asp:TextBox>
             <asp:Button ID="btMostrarIgualesEntrante" runat="server" Text="Revisar si ya existe"
                                                    OnClick="MostrarVentanaIgualesEntrante" ValidationGroup="none" CausesValidation="false"
                                                    CssClass="Button" />                 
             <asp:Label runat="server" ID="lbNumeroUnicoEntrante" Text="Debe digitar el formato correcto del número único (completo)"
                                                    Visible="false" CssClass="ErrorCampo"></asp:Label>
          </td>
       </tr>...
        <div id="DivMostrarIguales" title="Número Único Igual">
            WhatEver              
        </div>           
    </ContentTemplate>
</asp:UpdatePanel>
</asp:Content>

我的.CS功能

private string getjQueryCode(string jsCodetoRun)
    {
        StringBuilder sb = new StringBuilder();
        sb.AppendLine("$(document).ready(function() {");
        sb.AppendLine(jsCodetoRun);
        sb.AppendLine(" });");

        return sb.ToString();
    }

    private void runjQueryCode(string jsCodetoRun)
    {

        ScriptManager requestSM = ScriptManager.GetCurrent(this);
        if (requestSM != null && requestSM.IsInAsyncPostBack)
        {
            ScriptManager.RegisterClientScriptBlock(this,typeof(Page),Guid.NewGuid().ToString(),getjQueryCode(jsCodetoRun),true);
        }
        else
        {
            ClientScript.RegisterClientScriptBlock(typeof(Page),true);
        }
    }

    protected void MostrarVentanaIgualesEntrante(object sender,EventArgs e)
    {
        CargarGridMostrarIgualesEntrante();
        runjQueryCode("$('#DivMostrarIguales').dialog('open')");            
    }

解决方法

首先调用对话框来创建它.
.dialog({ autoOpen: false }) //{} = settings

然后打开它..

.dialog('open')

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...