473,503 Members | 2,157 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

some difficulties when displaying page content in MS Word format

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
3 1641
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
295
by: sonic | last post by:
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...
2
4845
by: sonic | last post by:
Hello, I've searched the web, and can't seem to find a good reference for msword ( content type ) formatting. I am presenting my information as microsoft word doc. I was able to format the text...
1
1861
by: Franck | last post by:
Hello, I'm trying to diplay the content of a word file on a aspx page only the content if possible... not the file I tried the folowing but it doesn't work... Response.ContentType =...
7
2432
by: SteveM | last post by:
I am sure this is an easy question, but being relatively new to ASP.NET programming, I can not quite grasp what I need to accomplish what I need to do. What I have is a word document that is...
20
4222
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
0
994
parshupooja
by: parshupooja | last post by:
Hello All, I am trying creating a page where to I should be able to upload Word document and after uploading word document screen on the page should display word document, exactly the way it is. ...
7
2876
by: robert.waters | last post by:
I have an Access database frontend linked via ODBC to a large (gigabytes) mysql database. I need to view a large amount of data in a a textbox (variable up to 300K), but I receive a 'there isnt...
2
20114
by: uamusa | last post by:
I am Dynamically generating a proposal(report) in MS Word. By default the Paragraph Alignment is "Left". For the First 6 Paragraphs I set the Alignment to "Center", and then when attempting to...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7287
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
7349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5594
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
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.