By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,087 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

some difficulties when displaying page content in MS Word format

P: n/a
Hi,
displaying information on a page as MS Word document seems to be as
simple as:

//OnLoad
Response.ContentType = "application/msword";
Response.Write ( MyContentString );

(this assuming intranet site environment with users ensured to use
certain version of MS Word on their workstations)

I am getting following 2 problems :
It seems that, when the content exceeds certain size, instead of
browser automatically loading content in ms word editor, it pops up the
"File Downlaod" dialog with Filename: MyPage.aspx which contains the
full HTML for the page.
Any idea why this happens ?

another problem is that in some cases i get the "convert file" dialog
which has "RTF" etc choices in the list box.

anyone knows what is causing those dialogs and how i could ensure they
don't pop up ?
TIA.

Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
For one thing, you need to specify a filename with a line like this:

Response.AddHeader("Content-Disposition", "inline;filename=test.doc")

As far as the convert dialog goes, it sounds like you might be outputting a
format with which Word is not familiar. It understands basic HTML for
example, so you could give it that.

Here's a bunch more information for you along with code samples:
http://steveorr.net/articles/ExcelExport.aspx
http://steveorr.net/articles/ExportPanel.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


"sonic" <so*******@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi,
displaying information on a page as MS Word document seems to be as
simple as:

//OnLoad
Response.ContentType = "application/msword";
Response.Write ( MyContentString );

(this assuming intranet site environment with users ensured to use
certain version of MS Word on their workstations)

I am getting following 2 problems :
It seems that, when the content exceeds certain size, instead of
browser automatically loading content in ms word editor, it pops up the
"File Downlaod" dialog with Filename: MyPage.aspx which contains the
full HTML for the page.
Any idea why this happens ?

another problem is that in some cases i get the "convert file" dialog
which has "RTF" etc choices in the list box.

anyone knows what is causing those dialogs and how i could ensure they
don't pop up ?
TIA.

Nov 19 '05 #2

P: n/a
Hi Steve,
I actually experimented with the content as HTML, and in the end was
outputting plain unformatted string with 2 words, while still getting
that convert file dialog. but i did not try messing with headers yet,
thanks for the suggestion and links !

Nov 19 '05 #3

P: n/a
ahh, it looks like i found the problem.

it looks like viewstate was being rendered into the word doc and when
it grew in size, word would not recognize the content as its own..

so i overwrote the page Render event, and instead of calling
base.Render() i only render the elements that hold the content that
needs to go into word document.
like this:

protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
if (!_displayWordFormat)
base.Render (writer);
else
DocumentContent.RenderControl( writer );
}

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.