【问题标题】:Why doesn't Server.HtmlDecode decodes data?为什么 Server.HtmlDecode 不解码数据?
【发布时间】:2016-04-27 09:59:55
【问题描述】:

我使用 Html TextArea 标签从数据库中获取 html 编码数据。

但它以原始形式显示数据,即带有标签等。

 <div class="col-md-12">
         <div class="form-group">
             <label class="control-label">
               test body
             </label>
             <textarea><%= Server.HtmlDecode(bodytext) %></textarea>
         </div>
 </div>

为什么?

正文是我在服务器端使用的字符串。

【问题讨论】:

    标签: c# asp.net c#-4.0 decode


    【解决方案1】:

    TEXTAREA 标记无法显示呈现的 HTML。 你需要一个特殊的组件来做到这一点,google 'html web editor wysiwyg'。

    【讨论】:

    • 我做到了。只是简单地发送 html 而不是解码
    【解决方案2】:

    @Cuckoo 你可以像下面这样使用“HttpUtility.HtmlDecode(string)”

        <div class="col-md-12">
             <div class="form-group">
                 <label class="control-label">
                   test body
                 </label>
                 <%= HttpUtility.HtmlDecode(bodytext) %>
             </div>
     </div>
    

    【讨论】:

      猜你喜欢
      • 2015-07-01
      • 2019-02-11
      • 1970-01-01
      • 2019-09-23
      • 2015-02-07
      • 2017-09-20
      • 1970-01-01
      • 1970-01-01
      • 2019-06-17
      相关资源
      最近更新 更多