i Need to save the Current aspx page as Html page when i hit button http://forums.asp.net/t/1774983.aspx/1?i+Need+to+save+the+Current+aspx+page+as+Html+page+when+i+hit+button+Wed, 29 Feb 2012 10:22:57 -050017749834856223http://forums.asp.net/p/1774983/4856223.aspx/1?i+Need+to+save+the+Current+aspx+page+as+Html+page+when+i+hit+button+i Need to save the Current aspx page as Html page when i hit button <p>i Need to save the Current aspx page when i hit button...How to save the current aspx page to one folder?</p> 2012-02-29T07:26:05-05:004856251http://forums.asp.net/p/1774983/4856251.aspx/1?Re+i+Need+to+save+the+Current+aspx+page+as+Html+page+when+i+hit+button+Re: i Need to save the Current aspx page as Html page when i hit button <p>What exactly do you want to achieve? Do you just want to copy aspx file from one folder to another one or you want to save browser output as a html file?</p> 2012-02-29T07:33:06-05:004856299http://forums.asp.net/p/1774983/4856299.aspx/1?Re+i+Need+to+save+the+Current+aspx+page+as+Html+page+when+i+hit+button+Re: i Need to save the Current aspx page as Html page when i hit button <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Honnappa</h4> <p></p> <p>i Need to save the Current aspx page when i hit button...How to save the current aspx page to one folder?</p> <p></p> </blockquote> <p></p> <p>&nbsp;use HttpWebRequest to ping that page, and get its response as html...then use FileStream to write html content to a html page and save it on server -&nbsp;<a href="http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx" target="_blank">http://msdn.microsoft.com/<wbr>en-us/library/system.io.<wbr>filestream.aspx</a>&nbsp;</p> <p>alternatively you can also use WebClient to get html response...</p> <p>Thanks,</p> 2012-02-29T07:49:52-05:004856350http://forums.asp.net/p/1774983/4856350.aspx/1?Re+i+Need+to+save+the+Current+aspx+page+as+Html+page+when+i+hit+button+Re: i Need to save the Current aspx page as Html page when i hit button <p>hi..try this..</p> <pre class="prettyprint">&lt;%@ Page Language=&quot;VB&quot; AutoEventWireup=&quot;false&quot; ValidateRequest=&quot;false&quot; CodeFile=&quot;Default3.aspx.vb&quot; Inherits=&quot;Default3&quot; %&gt; &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt; &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt; &lt;head id=&quot;Head1&quot; runat=&quot;server&quot;&gt; &lt;title&gt;View HTML&lt;/title&gt; &lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot;&gt; function sample(txtbox) { var src = document.documentElement.innerHTML; document.forms[0]['txtsam'].value = src; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt; &lt;div&gt; &lt;asp:Button ID=&quot;btnViewHtml&quot; runat=&quot;server&quot; Text=&quot;View Html&quot; /&gt; &lt;br /&gt; &lt;br /&gt; &lt;asp:TextBox ID=&quot;txtsam&quot; runat=&quot;server&quot; Height=&quot;235px&quot; TextMode=&quot;MultiLine&quot; Width=&quot;542px&quot;&gt;&lt;/asp:TextBox&gt;&lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; Partial Class Default3 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load btnViewHtml.Attributes.Add(&quot;onClick&quot;, &quot;javascript:sample()&quot;) End Sub End Class</pre> 2012-02-29T08:09:31-05:004856441http://forums.asp.net/p/1774983/4856441.aspx/1?Re+i+Need+to+save+the+Current+aspx+page+as+Html+page+when+i+hit+button+Re: i Need to save the Current aspx page as Html page when i hit button <p>i need to save Browser output as html page in a Zip folder</p> 2012-02-29T08:48:31-05:004856495http://forums.asp.net/p/1774983/4856495.aspx/1?Re+i+Need+to+save+the+Current+aspx+page+as+Html+page+when+i+hit+button+Re: i Need to save the Current aspx page as Html page when i hit button <p>Here is the code for saving the browser output on a button click (file will be saved in &quot;Output&quot; folder and the name of the file will be &quot;test.htm&quot; - you will have to adjust that to your needs):</p> <pre class="prettyprint">protected void Button1_Click(object sender, EventArgs e) { ViewState[&quot;Export&quot;] = true; } protected override void Render(HtmlTextWriter writer) { if (ViewState[&quot;Export&quot;] != null &amp;&amp; Convert.ToBoolean(ViewState[&quot;Export&quot;])) { ViewState[&quot;Export&quot;] = false; StringBuilder sb = new StringBuilder(); using (HtmlTextWriter tw = new HtmlTextWriter(new System.IO.StringWriter(sb))) { base.Render(tw); string sContent = sb.ToString(); using (StreamWriter sw = File.CreateText(Server.MapPath(&quot;~/test.htm&quot;))) { sw.WriteLine(sContent); sw.Close(); } writer.Write(sContent); } } else { base.Render(writer); } }</pre> <p>For zipping that file, use this library: <a href="http://dotnetzip.codeplex.com/"> http://dotnetzip.codeplex.com/</a></p> 2012-02-29T09:12:59-05:004856583http://forums.asp.net/p/1774983/4856583.aspx/1?Re+i+Need+to+save+the+Current+aspx+page+as+Html+page+when+i+hit+button+Re: i Need to save the Current aspx page as Html page when i hit button <p>According your code&nbsp; it will nt work</p> <p></p> <p>RegisterForEventValidation can only be called during Render();</p> 2012-02-29T09:54:46-05:004856592http://forums.asp.net/p/1774983/4856592.aspx/1?Re+i+Need+to+save+the+Current+aspx+page+as+Html+page+when+i+hit+button+Re: i Need to save the Current aspx page as Html page when i hit button <p>You can't expect that you will get proper help if you write just a few words... Post your code, let us know on what line you get error and than we will be able to help you.</p> 2012-02-29T09:59:15-05:004856648http://forums.asp.net/p/1774983/4856648.aspx/1?Re+i+Need+to+save+the+Current+aspx+page+as+Html+page+when+i+hit+button+Re: i Need to save the Current aspx page as Html page when i hit button <p>Sorry Kepo...Your code works Perfectly !!!</p> <p></p> <p>I was writing in Page load Event that was the problm</p> <p>Thanks</p> 2012-02-29T10:22:57-05:00