Open a text file in notepad in C# and ASP.Net

Discussion in 'ASP .Net' started by RNDAS, Apr 26, 2005.

  1. RNDAS

    RNDAS Guest

    Hi,
    I have a DataGrid in my web page and there is a column in that
    grid which template column with linkButton. When Clicked the
    linkButton it should not refresh the page, rather it should open a
    file in notepad. I am not able to resolve it. Can you please help
    me with code how to do it? I have spent days after days seraching
    Web, books with no luck. I am a newbie in .net.

    Thanks a lot
    Hope someone would be kind enough to provide me a solution.

    Das
    --
    POST BY: http://www.dotNET.us - Need .NET? Just ask, Please dotNET.us
    RNDAS, Apr 26, 2005
    #1
    1. Advertising

  2. RNDAS

    Nate Hekman Guest

    If I understand right you have a link to a .txt file and you want the file
    to open in Notepad rather than the browser. To do that the text file needs
    to be sent to the browser with a Content-Disposition: Attachment HTTP
    header, like this:

    Content-Disposition: Attachment; filename="YourTextFilename.txt"

    To send an HTTP header you'll have to generate the text file on demand. So
    for example, create a "downloadtextfile.aspx" file that you pass a filename
    to (downloadtextfile.aspx?filename=YourTextFilename.txt), and the OnLoad
    handler does something like this:

    Response.ContentType = "text/plain";
    Response.AppendHeader("content-disposition", "attachment; filename=\"" +
    Request.QueryString["filename"] + "\"");
    Response.Write( /* file contents go here */ );


    Nate Hekman


    "RNDAS" <> wrote in message
    news:%...
    > Hi,
    > I have a DataGrid in my web page and there is a column in that
    > grid which template column with linkButton. When Clicked the
    > linkButton it should not refresh the page, rather it should open a
    > file in notepad. I am not able to resolve it. Can you please help
    > me with code how to do it? I have spent days after days seraching
    > Web, books with no luck. I am a newbie in .net.
    >
    > Thanks a lot
    > Hope someone would be kind enough to provide me a solution.
    >
    > Das
    > --
    > POST BY: http://www.dotNET.us - Need .NET? Just ask, Please dotNET.us
    Nate Hekman, Apr 26, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Uk4gRGFz?=
    Replies:
    5
    Views:
    8,251
    srajput
    May 23, 2008
  2. PhuWong
    Replies:
    0
    Views:
    421
    PhuWong
    Feb 25, 2006
  3. Daves

    link to open txt file in notepad

    Daves, May 3, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    5,443
    Hans Kesting
    May 3, 2006
  4. boris
    Replies:
    1
    Views:
    1,803
  5. Anukul Singhal
    Replies:
    3
    Views:
    156
Loading...

Share This Page