C# ASP.NET 获取脚本语句并用文本的方式显示出来

来源:互联网 发布:甲骨文公司待遇知乎 编辑:程序博客网 时间:2024/04/29 09:21

protected void Button6_Click(object sender, EventArgs e)
    {
        this.Label11.Text = HtmlEncode(this.TextBox3.Text);
 
       
    }

    protected static string HtmlEncode(string the)
    {
   
        the = the.Replace("<", "&lt;");
        the = the.Replace(" ", "&nbsp;");
        the = the.Replace("/"", "&quot;");
        the = the.Replace("/'", "'");
        the = the.Replace("/n", "<br/> ");
        return the;

    }

 

通过在 Page 指令或 配置节中设置 validateRequest=false

 

就是在页面中加入

原创粉丝点击