使用c#将html文件内容显示到标签中 [英] Displaying the html file content into label using c#

查看:89
本文介绍了使用c#将html文件内容显示到标签中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用c#



将html文件内容显示到标签中我尝试了如下代码



页面加载我写的代码如下



string file = Server.MapPath(RM 5 Days.html);

StreamReader sr;

FileInfo fi = new FileInfo(file);

string input =

I want to display the html file content into label using c#

I tried my code as follows

In page load i written code as follows

string file = Server.MapPath("RM 5 Days.html");
StreamReader sr;
FileInfo fi = new FileInfo(file);
string input = "

";
       if (File.Exists(file))
       {
           sr = File.OpenText(file);
           input += Server.HtmlEncode(sr.ReadToEnd());
           sr.Close();
       }
       input += "

;

Label1.Text =输入;



但上面的代码不起作用。



当我执行label1中的上述代码时,无法显示。

请帮帮我。从上面的代码我犯了什么错误。

";
Label1.Text = input;

But the above code is not working.

When i execute the above code in label1 nothing to be displayed.
Please help me. From my above code what is the mistake i made.

推荐答案

你应该使用像div这样的任何html控件。

u should use any html control like div.





然后从代码dv1.innerHTML = input;



Then from code behind dv1.innerHTML=input;


这篇关于使用c#将html文件内容显示到标签中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆