UpdatePanel中弹出新窗口

时间:2021-11-30 23:39:19

如果允许,在UpdatePanel中使用iframe即可,不允许的话,用下面的方法实现弹窗

要在UpdatePanel中使用FileUpload时,会遇到此问题,或者同类其它情况

<asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
          <ContentTemplate>
              <asp:Button ID="Button1" runat="server" Text="弹出" onclick="Button1_Click" />
          </ContentTemplate>
        </asp:UpdatePanel>

后台代码:

protected void Button1_Click(object sender, EventArgs e)
    {
        string script = "window.open('test.aspx','newwindow','height=400,width=700,menubar=no')";
        ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "click", script, true);
    }