Reputation: 177
On the server I receive xml from a webservice, I use xslt transformation on this xml to create a htm page. Now I need to show this htm page to the user by opening it in a new browser window. How do I achieve such functionality? My website is written in ASP.NET.
I have tried using
Response.Write(""); Response.Write("window.open('" + Server.MapPath("~/App_Data/HTMLPage.htm") + "','_blank')"); Response.Write("");
But this throws me an access denied error.
Thanks in advance.
Chandrasekhar
Upvotes: 0
Views: 1820
Reputation: 6260
As I understood it, you want this new page to open in a new browser window, correct?
If so, you're going about it the wrong way. Response.Redirect will only redirect the current page, not instantiate a new browser window.
What you need to do is inject a JavaScript command into the page that opens a new browser page. That command is window.open. Here's a quick way to do it:
ClientScript.RegisterStartupScript(this.GetType(), "newpage", "window.open('" + address +"');", true);
This code will insert the JavaScript command to execute when the page reloads after submission. Note that address is the string variable that contains the address of the page you want to open.
Another very important note: most browsers will consider this a pop-up window and may very well block it.
Upvotes: 1