Response.OutputStream in a new page

  • Thread starter claudia villatoro via .NET 247
  • Start date
C

claudia villatoro via .NET 247

Hi

I have a page with an option for opening the result( dataset) inexcel and it works, but the excel's file opens in the currentpage, I'd like to open it in a new page, How could I do ? ( Ithink I have to change the Reponse.write, but I don't know thecorrect parameters ...)



I put my code :

....
'first let's clean up the response.object
response.Clear()
response.Charset = ""
'set the response mime type for excel
response.ContentType = "application/vnd.ms-excel"
'create a string writer
Dim stringWrite As New System.IO.StringWriter()
'create an htmltextwriter which uses thestringwriter
Dim htmlWrite As NewSystem.Web.UI.HtmlTextWriter(stringWrite)
'instantiate a datagrid
Dim dg As New DataGrid()
'set the datagrid datasource to the dataset passedin
dg.DataSource = dv
'bind the datagrid
dg.DataBind()
'tell the datagrid to render itself to ourhtmltextwriter
dg.RenderControl(htmlWrite)
'all that's left is to output the html
response.Write(stringWrite.ToString) <-- Do I changeit ? how ?
response.End()
 
B

Bruce Barker

it has to be done on the client side. client script needs to open a window,
or use an anchor with a target

-- bruce (sqlwork.com)



Hi

I have a page with an option for opening the result( dataset) in excel and
it works, but the excel's file opens in the current page, I'd like to open
it in a new page, How could I do ? ( I think I have to change the
Reponse.write, but I don't know the correct parameters ...)



I put my code :

....
'first let's clean up the response.object
response.Clear()
response.Charset = ""
'set the response mime type for excel
response.ContentType = "application/vnd.ms-excel"
'create a string writer
Dim stringWrite As New System.IO.StringWriter()
'create an htmltextwriter which uses the stringwriter
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
'instantiate a datagrid
Dim dg As New DataGrid()
'set the datagrid datasource to the dataset passed in
dg.DataSource = dv
'bind the datagrid
dg.DataBind()
'tell the datagrid to render itself to our htmltextwriter
dg.RenderControl(htmlWrite)
'all that's left is to output the html
response.Write(stringWrite.ToString) <-- Do I change it ? how ?
response.End()
 

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

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top