单击按钮后关闭弹出窗口

时间:2016-04-26 16:18:08

标签: asp.net vb.net

我在弹出窗口中有以下代码。我想在用户点击导出按钮

时关闭此弹出窗口
Protected Sub btnExport_Click(sender As Object, e As EventArgs) Handles btnExport.Click
    Try           
        Dim sw As New StringWriter()
        Dim w As New HtmlTextWriter(sw)
        gv.RenderControl(w)

        Dim content As String = sw.GetStringBuilder().ToString()

        'I have generate pdf code here
        'I want to close this popup       
    Catch ex As Exception

    End Try
End Sub

1 个答案:

答案 0 :(得分:1)

试试这个

ClientScript.RegisterStartupScript(GetType(), "winclose", "window.close();", true);

它生成客户端JavaScript,在呈现时将关闭当前窗口。