By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,583 Members | 617 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,583 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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" <ra*******@msn.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
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

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.