Results 1 to 5 of 5

Thread: [RESOLVED] How to download document file from server

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2010
    Posts
    66

    Resolved [RESOLVED] How to download document file from server

    Can any one help me with code for download (PPT) document from server using asp.net and c#.??

    Thanks in Advance..

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: How to download document file from server

    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2010
    Posts
    66

    Resolved Re: How to download document file from server

    Thanks for reply...I tried this solution. Its works perfectly.!!!!

    If you want to use linkbutton to download the file, please try the following method.

    Code:
    <ItemTemplate>
         <asp:LinkButton ID="LinkButton1" CommandArgument='<&#37;# Bind("FilePath") %>' CommandName="Select" runat="server">Print</asp:LinkButton>
    </ItemTemplate>
    Then you can send the bindary stream based of the CommandName property and CommandArgument property at event RowCommand.

    Code:
        protected void dvTest_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                string path = e.CommandArgument;
                Response.Clear();
                Response.ContentType = "application/ms-word";
                Response.AddHeader("Content-Disposition", "attachment; filename=test.doc");
                Response.TransmitFile(path);
                Response.End();
            }
        }
    Last edited by gep13; Feb 28th, 2012 at 02:25 AM. Reason: Added Code Tags

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] How to download document file from server

    Hello rnjnagu,

    Thanks for posting your solution, I am sure it will help others in the future.

    I have edited your above post to include CODE tags, which makes it slightly easier to read

    Gary

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2010
    Posts
    66

    Re: [RESOLVED] How to download document file from server

    No Probs Gep!!!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width