tags:

views:

1286

answers:

1

I’d like to be able to open a text/html file and write its contents to a container, either an HTML div or an asp label would be fine. How do I go about doing this in the C# codefile for the page in question?

+3  A: 

You just want to stream in the file and place the text into the Label.text field:

lable1.text= System.IO.File.ReadAllText( path );
Glennular
Great answer +1, but with a label, it's InnerText or InnerHtml.
IainMH
Yes: the .Text property will escape things like < for you. You could also use a literal control- that may be more what you really want.
Joel Coehoorn