473,388 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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.us
Nov 19 '05 #1
1 3108
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jesper | last post by:
How can I open a textfile from C# using notepad (or the user assigned application for this).
8
by: Juan Manuel Alegrķa B. | last post by:
Hi group!!! I am new in the ASP.NET programming. I am trying to open a ..txt file but I can't do it. I am using: but i don't know if its the right way. Thanks for help me. Dim proc As New...
3
by: RN Das | last post by:
Hi expert, I have a small web application in C# and ASP.Net and I want to open a file in notepad when clicked on a linked button. Here is hander code when clicked on the link button. It can open...
7
by: Lumpierbritches | last post by:
Thank you in advance for any and all assistance. It is greatly appreciated. I would like a command button in VB.Net 2002 to open a text file, then to allow text from a textbox on the current form...
2
by: Seok Bee | last post by:
Dear Experts, In my web application, I am having a button to open a file located in the server. When I click on the button to view the file, I received the following error message:...
13
by: Chris Johnson | last post by:
I have what seems to be such a simple thing yet I cannot figure out how to do it. I am using a streamwriter to build a text file. At the end of the process I want to open that same text file in...
6
by: Moumen VB.NET 2003/2005 Developer | last post by:
How can I detect if a file sitting on a network drive is still open by another application? This application resides on another machine on the network? I am using VB.NET 2003 Your help is...
2
by: Bob | last post by:
Looking at shell command I don't see how I can specify the filename to open. I need to launch notepad AND automatically open an existing file. Using VB 2005. Any help would be greatly...
25
by: stefbek97 | last post by:
Hello All, I am having a bit of trouble opening a file in my ASP.Net/C# Application. I have a file Path and name stored in my Database. I display that filename in a Gridview control. I also have a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.