Friday, March 16, 2012

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

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.usIf 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" <rabindrad@.msn.com> wrote in message
news:%23CQGmypSFHA.584@.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

0 comments:

Post a Comment