Ajax弹出窗口导致使用ASP.NET重新加载屏幕

时间:2009-10-15 16:00:51

标签: asp.net ajax popup

我正在使用 How to create a stunning and smooth popup using jQuery 中的代码。当我单击按钮激活Ajax弹出窗口时,它会出现,但页面会在按钮单击时重新加载。

我该如何解决这个问题?

4 个答案:

答案 0 :(得分:1)

很难说没有看到你的代码,但是你用来启动对话框的链接/按钮,确保它从click事件处理程序返回false(或在表单上提交事件处理程序)

答案 1 :(得分:0)

您的模态是否连接到ASP.NET按钮?如果是这样,这将设置为单击回发。也许将模态连接到常规HTML按钮?

答案 2 :(得分:0)

您的按钮很可能是一个回发按钮。您可能希望更改该配置,以便它不会自动回发。

答案 3 :(得分:0)

由于我使用的是ASP.NET按钮控件,因此我想回发,因此我使用AsyncPostBackTrigger ControlID=[my button id]创建了一个更新面板。

因此,使所有工作(加载jQuery库)的代码如下:

<form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

        <div id="button">
                <asp:Button ID="Save1" runat="server" Text="Button" onclick="Save1_Click" />
        </div>

        <asp:UpdatePanel ID="up1" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Save1" />
            </Triggers>
            <ContentTemplate>
            </ContentTemplate>
        </asp:UpdatePanel>

        <div id="popupContact">
            <a id="popupContactClose">x</a>
            <h1>Title of our cool popup, yay!</h1>

            <p id="contactArea">
                Here we have a simple but interesting sample of our new stuning and smooth popup. As you can see jQuery and CSS does it easy...
                <br/><br/>
                We can use it for popup-forms and more... just experiment!
                <br/><br/>
                Press ESCAPE, Click on X (right-top) or Click Out from the popup to close the popup!
                <br/><br/>
            </p>
        </div>
        <div id="backgroundPopup"></div>
    </div>
</form>