Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Open a text file in notepad in C# and ASP.Net

Reply
Thread Tools

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

 
 
RNDAS
Guest
Posts: n/a
 
      04-26-2005
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
 
Reply With Quote
 
 
 
 
Nate Hekman
Guest
Posts: n/a
 
      04-26-2005
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.t xt), 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to open text file (.log, .txt etc) in notepad from aspnet =?Utf-8?B?Uk4gRGFz?= ASP .Net 5 05-23-2008 06:53 AM
Can I write text to a notepad and save the file through ruby Anukul Singhal Ruby 3 03-21-2008 12:59 AM
how to use io operations with open/save file dialog box in file menu for simple notepad boris Java 1 07-22-2007 04:13 PM
link to open txt file in notepad Daves ASP .Net 1 05-03-2006 12:51 PM
Unicode text file shown in popped-up Notepad window yong321@yahoo.com Computer Support 1 08-16-2005 03:29 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57