Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 打开一个文件并将内容写入DIV、span、label或某种容器_C#_Asp.net_Html - Fatal编程技术网

C# 打开一个文件并将内容写入DIV、span、label或某种容器

C# 打开一个文件并将内容写入DIV、span、label或某种容器,c#,asp.net,html,C#,Asp.net,Html,我希望能够打开一个text/html文件并将其内容写入一个容器,无论是html div还是asp标签都可以。 如何在相关页面的C#代码文件中执行此操作?您只需在文件中进行流式处理,并将文本放入Label.text字段: lable1.text= System.IO.File.ReadAllText( path ); 我想有一个问题和3-4天前的这个差不多一样。。。试图找到它,但没有运气。有人吗?很好的答案+1,但是有一个标签,它是InnerText或InnerHtml。是的,.Text属性将为

我希望能够打开一个text/html文件并将其内容写入一个容器,无论是html div还是asp标签都可以。
如何在相关页面的C#代码文件中执行此操作?

您只需在文件中进行流式处理,并将文本放入Label.text字段:

lable1.text= System.IO.File.ReadAllText( path );

我想有一个问题和3-4天前的这个差不多一样。。。试图找到它,但没有运气。有人吗?很好的答案+1,但是有一个标签,它是InnerText或InnerHtml。是的,.Text属性将为您转义<之类的内容。您还可以使用文字控件-这可能更符合您的实际需要。