Live Chat Icon For mobile
Live Chat Icon

How to close the browser window on button control click

Platform: ASP.NET| Category: Controls

Method 1. This will cause a postback on button click in response to which we will send some script to close the window.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub

private void Button1_Click(object sender, System.EventArgs e)

Method 2. This is preferable since there is no postback involved.

Use the Attribute collections i.e use Attributes of button control to add client side JavaScript code
	 Button1.Attributes.Add('OnClick', 'window.close();')

	 Button1.Attributes.Add('OnClick', 'window.close();');

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.