| |
microsoft.public.dotnet.framework.aspnet |
Thanks Teemu! That's perfect! Ken > it complained for me about event validation , so when disabling it with > <%@ Page Language="VB" %> > <script runat="server"> > Protected Overrides Sub Render(ByVal writer As > Try > MyBase.Render(tWriter) > 'save the rendered output to a file > ' redirect to another page > writer.Write(renderedOutput.ToString()) > 'clean up > If (Not IsNothing(tWriter)) Then > If (Not IsNothing(strWriter)) Then > </script> > <html xmlns="http://www.w3.org/1999/xhtml" > > Is that what you are looking for? > Teemu
> **
> Hello,
> EnableEventValidation="False" helped. But, if you try it this way e.g
> moving the code to overridden Render method
> System.Web.UI.HtmlTextWriter)
> Const OUTPUT_FILENAME As String = "renderedpage.html"
> Dim renderedOutput As StringBuilder = Nothing
> Dim strWriter As IO.StringWriter = Nothing
> Dim tWriter As HtmlTextWriter = Nothing
> Dim outputStream As IO.FileStream = Nothing
> Dim sWriter As IO.StreamWriter = Nothing
> Dim filename As String
> Dim nextPage As String
> 'create a HtmlTextWriter to use for rendering the page
> renderedOutput = New StringBuilder
> strWriter = New IO.StringWriter(renderedOutput)
> tWriter = New HtmlTextWriter(strWriter)
> filename = Server.MapPath(".") & "\" & OUTPUT_FILENAME
> outputStream = New IO.FileStream(filename, _
> IO.FileMode.Create)
> sWriter = New IO.StreamWriter(outputStream)
> sWriter.Write(renderedOutput.ToString())
> sWriter.Flush()
> ' NOTE: Continuing with the display of this page will result
> in the
> ' page being rendered a second time which will cause an
> exception
> ' to be thrown
> nextPage = "DisplayMessage.aspx?" & _
> "PageHeader=Information" & "&" & _
> "Message1=HTML Output Saved To " & OUTPUT_FILENAME
> 'Response.Redirect(nextPage)
> 'Response.Write(renderedOutput.ToString())
> Finally
> If (Not IsNothing(outputStream)) Then
> outputStream.Close()
> End If
> tWriter.Close()
> End If
> strWriter.Close()
> End If
> End Try
> End Sub
> <head id="Head1" runat="server">
> <title>Capture Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <asp:dropdownlist id="DropDownList1" runat="server">
> <asp:listitem>red</asp:listitem>
> <asp:listitem>blue</asp:listitem>
> <asp:listitem>green</asp:listitem>
> </asp:dropdownlist></div>
> </form>
> </body>