Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi,
My web page contains two button i.e
<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.
        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 26-Jan-12 8:15am
Edited 26-Jan-12 8:18am
v2
Comments
ryanb31 at 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 at 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 at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

<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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
Member 4391175 at 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
SAKryukov at 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)

  Print Answers RSS
0 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 255
2 Shweta N Mishra 216
3 Maciej Los 210
4 PIEBALDconsult 174
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,665


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 26 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100