Nemi Pujara
Nemi Pujara

Reputation: 71

Close popup after button click

I have below code in popup. I want to close this popup when user clicks on export button,

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

Upvotes: 2

Views: 496

Answers (1)

suff trek
suff trek

Reputation: 39777

Try this

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

It generates client-side JavaScript that will close current window when rendered.

Upvotes: 1

Related Questions