ali raza

C#, .Net ,Asp.net and my thoughts

How to open webform in new popup brower window from code behind

PopUp form can be open through two ways from code behind, you can use both way , parameters can be send through Query string as well


protected void Button1_Click(object sender, EventArgs e){
OpenNewWindow(”test.aspx”);
OpenNewWindowUsingResponse("test.aspx");
}

public void OpenNewWindow(string url)
{
ClientScript.RegisterStartupScript(this.GetType(), “newWindow”, String.Format(”<script>window.open(’{0}’);</script>”, url));
}

Public Void OpenNewWindowUsingResponse(string Url)
{
Response.Write("<scr" + "ipt>\r\n");
Response.Write("open('" + Url + "');\r\n");
Response.Write("</scr" + "ipt>");

}

Both Works fine

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: