Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
how can i open a form in a new tab from button click on server side. when we do response.redirect it will open page in same tab . i want to open that page in a new tab. i tried window.location script but that will open new form as a pop up window and not a new tab. can anyone please tell me how can i achieve this ?
Posted
Comments
JoCodes 21-Jan-14 5:09am    
Can you make it more clear? You say dont want popup ? Means you need to open in new tab instead of new window|?
ravikhoda 21-Jan-14 5:16am    
i want to open form in new tab but using Response.redirect. not from the html itself where i can set target="_blank" or target="_new".
njammy 21-Jan-14 5:13am    
This can depend on the user's browser tab settings which may override your code. IE has options like 'Open pop ups in new tab,new window' then theres options in there to 'switch to new tab when opened' etc.
ravikhoda 21-Jan-14 5:18am    
if i simply write response.redirect it wil open it the same tab. what i use javascript from response.write like window.location , "_newtab" ..browser asks that this site wants to open a new popup do you want to allow popup for this site.?? this is my main concern.
can you provide me some link or ref.
JoCodes 21-Jan-14 5:22am    
Which is your browser?

Try This:

ScriptManager.RegisterStartupScript(Me, Me.GetType(), "key", "window.open('vehicle_trackView.aspx');", True)
 
Share this answer
 
Please try this..

I have tested this in IE.

protected void Page_Load(object sender, EventArgs e)
   {
       if (!IsPostBack)
       {
           Response.Write("<script>");
           Response.Write("window.open('Default2.aspx','_blank')");
           Response.Write("</script>");
       }

   }
 
Share this answer
 
v2
use window.open. Like this:
C#
protected void btnNewEntry_Click(object sender, EventArgs e)
{
   Page.ClientScript.RegisterStartupScript(this.GetType(),"OpenWindow","window.open('YourURL','_newtab');",true);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900