Click to See Complete Forum and Search --> : How to save the to be generated HTML page onto the client's disk in ASP .NET 2.0?


ppuniversal
January 9th, 2008, 01:36 PM
Hi All,
My question is as follows:

I have a text box and two links.Let the two links be - Show and Save .

On clicking the Show , a web page is generated by fetching some data from database according to the input in the textbox and the web page is displayed to the user.

Now on clicking Save also, with the same input to the textbox, the same set of data will be fetched from the database, but in this case I do not want the web page generated to be displayed to the user, but want a Save dialog box to appear, which the user uses to select any location on his/her system to save the web page generated as HTML format.
How can I achieve this i.e. how can I save a page which will be generated on clicking the link without first displaying it to the user.

I have seen code where there is a button in the second web page which can be clicked to save the same page, but I not getting any thing to save the page which will be generated and saved directly.

I am using ASP .NET with VB .

Please provide my some solution.
Thanks
Pawan

Yeorwned
January 9th, 2008, 02:16 PM
By default, most browsers are set to open HTML pages automatically. Thus, your save as dialog box is no mre. You can change the response type to another format which the clients browser will not attempt to automatically open.

If you we're using the Response namespace...
Response.ContentType = "application/ms-txt"instead ofResponse.ContentType = "text/plain"should work instead. I may be wrong on the replacement ContentType but that's what I'd try off the top of my head.

ppuniversal
January 9th, 2008, 10:45 PM
Thanks
I will try this, and will reply whether I succeeded or not.

Thanks
Pawan