怎样才能清除所指定字段中的中的html样式!急!急!急!
<p ><%#Eval("EDescription").ToString().Length > 500 ? Eval("EDescription").ToString().Substring(0, 497) + "..." : Eval("EDescription").ToString()%>
</p>在前台去除字段“EDescription”含的Html格式  

解决方案 »

  1.   

    你是说去掉<>标签吧 ?
      

  2.   

    去掉<>标签 急!急!
      

  3.   

    那为什么 还要加上<p >
      

  4.   

    Regex.Replace(htmlstr, "<[^>]+>", "");
      

  5.   

    public static string DropHTML(string strHtml)
    {
       return Regex.Replace(strHtml, "<[^>]*>", "");
    }
      

  6.   

    和<p>没关系
    只是<%#Eval("EDescription").ToString().Length > 500 ? Eval("EDescription").ToString().Substring(0, 497) + "..." : Eval("EDescription").ToString()%>
      

  7.   

    protected string GetDesc(string desc){
    desc = Regex.Replace(desc, @"<.+?>", "");
    if(desc.Length>500) desc = desc.SubString(0,500);
    return desc;
    }<%# GetDesc(Eval("EDescription").ToString()) %>
      

  8.   

    你把这个字段绑定在Label上,然后调用JS方法去除html格式,我的测试代码如下<html>
    <head>
    <script>
    function show(){
    alert(document.getElementById("tb").innerText);
    alert(document.getElementById("sp").innerText);
    }
    </script>
    </head>
    <body>
    <table id='tb'><tr><td>innerText2</td></tr></table>
    <input type="button" id="btn" value="Show innerText" onclick="show()">
    <span id='sp'>测试代码测试测试啊<span>
    </body>
    </html>