Monday, February 11, 2008

Open a webpage on button click in asp.net using C#

Sometimes we need to open a web page using a button click event. This post contains a sample code that can be used in a button click event to show a page using Javascript Window.open method. This code snippet is just a small piece just to give you an idea for the startup stuff. I hope you can improve, and modify it according to your need to achieve your required goal.

Here is the sample code. You can put this code in the click event of a button etc.


string strpage = "Url of the page to be opened";
string url = "";
this.RegisterStartupScript("", url);

No comments: