阻止Jquery对话框关闭页面加载

时间:2017-09-11 11:04:34

标签: asp.net

我的Jquery Dialog调用.ascx页面。问题是,在.ascx.cs的每次PageLoad上,它关闭对话框。我添加了

ScriptManager.RegisterStartupScript(this, this.GetType(), "pop", "loadModal(" + id + ");", true);

再次打开模式但我想从代码中删除此脚本并希望数据更新而不回发并保持对话框打开。

2 个答案:

答案 0 :(得分:0)

使用此:

        if (!IsPostBack)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "pop", "loadModal(" + id + ");", true);
        }

答案 1 :(得分:0)

使用UpdateMode ="条件"

的更新面板

因此,当您转到服务器端时,它不会更新您的整个页面,而只会更新您的模式中的内容,以便模式不会被关闭。

  <asp:UpdatePanel ID="updModal" runat="server">
        <ContentTemplate>
               <asp:Button ID="TestButton" runat="server" Text="Test Button" onclick="TestButton_Click" />
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>         
        </ContentTemplate>