【问题标题】:Decoding Html string in mvcContrib在 mvcContrib 中解码 Html 字符串
【发布时间】:2010-08-20 14:30:18
【问题描述】:

我的问题很简单。

如何在 mvc contrib 网格中解码 Html 字符?我希望那些在解码后在 textarea 中呈现。但不幸的是,我在 textarea 中得到的所有编码信息。以下是我尝试执行此操作的方式...

column.For ( cust => Html.TextArea("Customer", new HtmlString(cust.Address), 4, 40, new  { @class = "custAddress" }) ) 
.Named("Address")
.DoNotEncode();

在 HtmlString() 返回的对象下,上面给了我红色下划线的错误,这显然是因为 TextArea 的第二个参数需要字符串值。

数据库中的地址字段包含土耳其语字符。我在 textarea 中得到的所有内容都是 þlseķ 等字符。但我希望这些信息能够被解码,无论如何

任何帮助将不胜感激。 谢谢。

【问题讨论】:

    标签: asp.net-mvc mvccontrib


    【解决方案1】:

    试试这个:

    Html.TextArea("Customer", (new HtmlString(cust.Address)).ToHtmlString(), 4, 40, new { @class= "custAddress" })

    【讨论】:

      【解决方案2】:

      您需要 HtmlString 吗?我试过了,我的 unicode 字符渲染正确。

      column.For ( cust => Html.TextArea("Customer", cust.Address, 4, 40, new  { @class = "custAddress" }) ) 
      .Named("Address")
      .DoNotEncode();
      

      【讨论】:

        猜你喜欢
        • 2010-10-29
        • 2022-01-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-22
        • 2010-11-09
        • 2018-07-02
        相关资源
        最近更新 更多