Task: Open a new
window using c# code in asp.net website/web application.
Description: The
problem is this we can use Response.Redirect() method for redirect/open new webpage in same window, But how we can
open a new page in new window.
So that I use javascript code(alert box) for popup new
window in c# code behind file as describe below. I write below code on Button
Click Event.
// Dynamic Alert box javascript using c# code in asp.net
protected void btngeneraterecipt_Click(object sender, EventArgs e)
{
try
{
string queryString = "billformat.aspx";
string jquery = "window.open('" + queryString + "');";
ScriptManager.RegisterStartupScript(this,this.GetType(), "pop", jquery, true);
}
catch (Exception ee)
{
Label1.Text = ee.Message;
}
}
Its totally working! thanks so much! :)
ReplyDeletewhile we use this code, popup blocker blocks. how can we remove the popup blocker???
ReplyDeleteThis is a javascript code so that popup will comes.
DeleteIt cant block. you can use different approach to do this.
plz tell me how to open a new page in new tab..... without using popup..... when i click btn.. it opens new page directly...........means we need not to allow popups...
ReplyDeleteHi,
DeleteOn Button Click I found only this method,On Server Side Coding I cant open page in new tab BUT if you make Link(hyperlink) Then you can open new page in new tab(you can manage link dynamically)... :-)
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_link_target
DeleteHmm.. you are right as I said previously using hyperlink we can open new page in new tab...
DeleteBut I think she want's On Button Click Event using back-end(c#) code...
Thanks bro !
ReplyDeleteHi,
ReplyDeleteI am using Sandbox solution. In that solution scriptManager is not working.Can U plz suggest another way to achieve.
Regards
Jacob
I already replied to others, I didn't found any other solution for it yet. From code page I have only this way...
Deleteavoid popup blocker setting open new popup window in asp.net using C#
ReplyDelete