How to write output of aspx file created to HTML programmatically

G

G

Hi, I have an aspx file that has a table with a couple of grids in it
that I'm using as a template to build html files(please give me
guidence if there is a better way). I would like to build this page
and then write the html it produces to a file in the asp.net
application. I tried the code below, but it only writes a blank html
file.

Thanks,

C

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Try
'set connection stream
'connect
'bind results to a data_grid
'.....

End Try

Me.Response.WriteFile("the_file_I_just_built.htm")

End Sub
 
C

Craig Deelsnyder

Hi, I have an aspx file that has a table with a couple of grids in it
that I'm using as a template to build html files(please give me
guidence if there is a better way). I would like to build this page
and then write the html it produces to a file in the asp.net
application. I tried the code below, but it only writes a blank html
file.

Thanks,

C

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Try
'set connection stream
'connect
'bind results to a data_grid
'.....

End Try

Me.Response.WriteFile("the_file_I_just_built.htm")

End Sub

You have to call Render on a control and send the output to an HTML
writer...see this for a simliar function:

http://www.dotnetjohn.com/articles/articleid78.aspx

I might also recommend using an HttpWebRequest to make a separate
request to your page (note you'd need to create a page to do this, don't
do it in the template page, it'll overflow!) and with that you get the
response html as well. Google on that term (HttpWebRequest) to see
xamples...
 
G

G

Craig Deelsnyder said:
You have to call Render on a control and send the output to an HTML
writer...see this for a simliar function:

http://www.dotnetjohn.com/articles/articleid78.aspx

I might also recommend using an HttpWebRequest to make a separate
request to your page (note you'd need to create a page to do this, don't
do it in the template page, it'll overflow!) and with that you get the
response html as well. Google on that term (HttpWebRequest) to see
xamples...


Thanks for the suggestion, however, I don't think this is quite what I
want. I don't want to export just one grid at a time, but a whole page
with has 2 or 5 grids on them. This html page will be nicely formated
for the public.

If I were to step through what is being developed, it would be
something like this:

1) A seperate page in the asp.net application has an export button.
2) The button event has a loop that then calls this html builder code,
that I'm trying to write, 4 times for the 4 different zones.
3) For each zone an html page is created. Depending on the zone, 2 to
5 grids on the page will be populated and made visible. These html
pages will be created in the direcotory of the asp.net application and
are just plain html files.
4) A seperate ftp program will ftp these files up to our external
server for the public to see.

Thanks,

G
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top