Okay, so I know you can open a new window using javascript. The problem is that I am using a server-side language so I do not have to be dependent on client-side scripting for things to work.
Therefore I want a solution that does not involve javascript.
I've searched around and tried several things such as:
Response.Redirect("newpage.aspx", False)
However, this still opens the new page in the same browser window.
Therefore I want a solution that does not involve javascript.
There is no way to make ASP.NET open a new browser window. However,you can include dynamically generated Javascript code to open a new window. check this..
if you need to do a postback from your first page then indeed you have to inject some javascript to open it up in a new window with the clientscriptmanager registerstartupscript method.
On the other hand if you don't need to do a postback first you can simply use a hyperlink control and set the
Target property to _blank.
Response.Redirect is a method to let the browser know that it should navigate to an new provided url.
Grz, Kris.
Read my blog | Twitter Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
So, I've decided on two possible ways that I will do this:
1) I will use an asp hyperlink and modify the code-behind to point to the document and open in a new window
2) If I want to use a button, I will create an ASP label. Inside that label I will place an HTML button that is wrapped with an HTML anchor tag that has a target="_blank". This will provide the end-user with the illusion that the button is doing the work
when in reality its a hyperlink.
Both of these solutions provide me with a way to open a new page without resulting to javascript.
KJAK
Participant
1673 Points
478 Posts
Open new Window Without using Javascript
Apr 02, 2009 07:35 PM|LINK
Okay, so I know you can open a new window using javascript. The problem is that I am using a server-side language so I do not have to be dependent on client-side scripting for things to work.
Therefore I want a solution that does not involve javascript.
I've searched around and tried several things such as:
Response.Redirect("newpage.aspx", False)However, this still opens the new page in the same browser window.
Using .NET, how can I force a new window to open?
KJAK
budugu
All-Star
41132 Points
6021 Posts
Re: Open new Window Without using Javascript
Apr 02, 2009 07:48 PM|LINK
There is no way to make ASP.NET open a new browser window. However,you can include dynamically generated Javascript code to open a new window. check this..
ClientScript.RegisterStartupScript(this.GetType, "popup", "window.open('YourURL','_blank','menubar=no')", true);"Don't be afraid to be wrong; otherwise you'll never be right."
XIII
All-Star
182707 Points
23464 Posts
ASPInsiders
Moderator
MVP
Re: Open new Window Without using Javascript
Apr 02, 2009 07:51 PM|LINK
Hi,
if you need to do a postback from your first page then indeed you have to inject some javascript to open it up in a new window with the clientscriptmanager registerstartupscript method.
On the other hand if you don't need to do a postback first you can simply use a hyperlink control and set the Target property to _blank.
Response.Redirect is a method to let the browser know that it should navigate to an new provided url.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
KJAK
Participant
1673 Points
478 Posts
Re: Open new Window Without using Javascript
Apr 03, 2009 12:49 PM|LINK
So, I've decided on two possible ways that I will do this:
1) I will use an asp hyperlink and modify the code-behind to point to the document and open in a new window
2) If I want to use a button, I will create an ASP label. Inside that label I will place an HTML button that is wrapped with an HTML anchor tag that has a target="_blank". This will provide the end-user with the illusion that the button is doing the work when in reality its a hyperlink.
Both of these solutions provide me with a way to open a new page without resulting to javascript.
Thanks for the replies!
[:)]
KJAK