Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi , i am new to .net
file can be uploaded using fileupload control,path is also set to save the file.now wat i want to do :i want to view the uploaded file contents in textbox in the same aspx page . pls send me the code. uploaded file content may be word document /img/pdf, i want to view the contents in
textbox
Posted
Updated 22-Mar-11 21:50pm
v2
Comments
Kumar Prashant Singh 11-Dec-13 2:28am    
This article is not working for me?

1 solution

Try to read this article File Upload with ASP.NET[^]

For the assignment of content to textbox you can use this code below:
TextBox txtData; // assume this is your text box control
FileUpload fileUpload; //your fileupload control
StreamReader r = new StreamReader(fileUpload.FileContent);
txtData.Text = r.ReadToEnd();
 
Share this answer
 
Comments
srinvas 25-May-12 11:08am    
hi but i think we get only encoded text in textbox.what to do to get the orginal text.
srinvas 25-May-12 11:10am    
i had tried with StreamReader r = new StreamReader(Fileupload.FileContent, UnicodeEncoding.GetEncoding("UTF-8")); and
StreamReader r = new StreamReader(Fileupload.FileContent,encoding.default));
but i still get the same encoded text please can anyone has the answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900