473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

HtmlTextWriter, Excel, New Window

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...b;en-us;317719

Thanks
Nov 19 '05 #1
2 3470
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).

"Steve Schroeder" wrote:
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...b;en-us;317719

Thanks

Nov 19 '05 #2
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("dgInv oice").outerhtml

Doesn't work, unfortunately...ideas?

Thanks
"Dave Bacher" <Da********@discussions.microsoft.com> wrote in message
news:D1**********************************@microsof t.com...
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).

"Steve Schroeder" wrote:
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...b;en-us;317719

Thanks

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mabond | last post by:
Firstly I hope I'm in the right forum ..... if not can someone re-direct me please. I have an application with a main form properties set to mdiparent = true. Toolbar button allows user to open...
3
by: Otie | last post by:
I found the following under the GetObject help notes and in the example for GetObject: "This example uses the GetObject function to get a reference to a specific Microsoft Excel worksheet...
6
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C#...
8
by: DC Gringo | last post by:
I have a simple button that should open another window and export a datagrid to an Excel file. I'm getting: "Name 'window' is not declared." What do I need to declare or import? <INPUT...
3
by: Lee Chapman | last post by:
Hi, I want my ASP.NET web application to use a custom HtmlTextWriter. i.e. I want the object that the Framework passes to System.Web.UI.Control.Render() to be my own object, MyHtmlTextWriter,...
0
by: mabond | last post by:
Firstly I hope I'm in the right forum ..... if not can someone re-direct me please. I have an application with a main form properties set to mdiparent = true. Toolbar button allows user to open...
1
by: garry.oxnard | last post by:
Can anyone help me to solve a problem which involves switching from Access to Excel (then back to Access) programatically please? I have an Excel template which, on open, also opens an Access...
0
by: John Walker | last post by:
Hi, I have an asp.net application which binds a dataview to a datagrid, which then renders control to an HtmlTextWriter and then by doing a "response.write" my datagrid is successfully displayed...
2
by: iloveprincess | last post by:
Hi, I'm developing windows application using VB.Net 2005. I would like to send 'save' message using 'SendMessage' API to the excel appication. I've already got a handle of the excel window with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.