Click here to Skip to main content
15,891,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
My web page contains two button i.e
XML
<asp:button id="btnOpenword" runat="server" text="OpenFile">
<asp:button id="btnNext" runat="server" text="Next" visible="false">

when i click on the OpenFile Button i need to open the word document and also below the Next button should visible to the user.
so i write some code but it's working to open the word document, but it's not visible the Next button to the user.
C#
btnNext.Visible = true;
FileInfo file = new FileInfo("filename.doc");
Response.ClearContent();
Response.AddHeader("Content-Disposition", "inline;filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/msword";
Response.TransmitFile(file.FullName);
Response.End();

Plese give me solution
Thanks ,
Suresh
Posted
Updated 26-Jan-12 7:18am
v2
Comments
ZurdoDev 26-Jan-12 13:52pm    
You are clearing out the Response and then ending it. You effectively are overwriting the response so nothing on the page is visible. You'll have to have some JavaScript to make the button visible from the client side.
Member 4391175 26-Jan-12 14:00pm    
Thanks your reply,

how to use javascript code to visible the button.

please send me code

Thanks,
Suresh
Member 4391175 26-Jan-12 14:48pm    
When i clcik the button i want to open the word document in separate window and after the button should visible to the user.

or any other way to do this

Thanks
Suresh

XML
<asp:button id="btnNext" runat="server" text="Next" visible="false">


The 'Next' button will not be rendered to html because visible="false".

Use an UpdatePanel and set visible to true when the user has downloaded the document, you can learn how to use it at ASP.NET AJAX[^]

Best regards
Espen Harlinn
 
Share this answer
 
You can open the Word document, but you cannot present it on the Web page as is, as the Word format is proprietary, not included in W3 standards. In most situation, you will need to work through HTML. I'll explain what do I mean.

Please see my past answer:
how can create word documents in asp.net windows application[^].

—SA
 
Share this answer
 
Comments
Member 4391175 26-Jan-12 14:48pm    
When i clcik the button i want to open the word document in separate window and after the button should visible to the user.

or any other way to do this

Thanks
Suresh
Sergey Alexandrovich Kryukov 2-May-12 1:34am    
Read my referenced post again: Word is proprietary, Web does not support it. The work is only imitated. You need to present Word document as HTML. Or PDF -- it is supported by add-ons, plug-int, etc. Not Word.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900