HtmlTextWriter, Excel, New Window

S

Steve Schroeder

Using this code, how might I render the results to a new browser window and
leave the original as it? Thanks...

Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
dgInvoice.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()

FYI...not my code, source is:
http://support.microsoft.com/default.aspx?scid=kb;en-us;317719

Thanks
 
G

Guest

There is a good Microsoft example (not the one you're quoting) showing this,
but the typical approach is:

<input type="button"
onclick='Window.Open("http://example.com/MyAspPage.aspx?bExcel=true")'>Click
here for Excel</input>

Then you use the QueryString server side to determine if it is a request for
Excel. There are numerous variations on this. What you don't want to do is
use the MIME type in the URL, because then someone can specify any random
MIME type and could use it as an attack mechanism (if unvalidated).
 
S

Steve Schroeder

Yeah I've decided on automation, that's cool.

Running into the problem now of making a proper DHTML reference to the
datagrid. Not too familar with DHTML...

window.document.forms("MGInvoice").children("dgInvoice").outerhtml

Doesn't work, unfortunately...ideas?

Thanks
 

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top