【问题标题】:Simple text does not render properly in a html input tag from resx file简单文本无法在 resx 文件的 html 输入标记中正确呈现
【发布时间】:2013-12-10 19:22:14
【问题描述】:

在 resx 文件中我有一个条目:

AccountRegisterSubmit = Create a new account

在我看来:

@{
    ViewBag.Submit = @Resources.AccountRegisterSubmit;
}

    <div>
        <input type="submit" value=@ViewBag.Submit />
    </div>

生成的 HTML 格式错误

<input type="submit" value="Create" a="" new="" account="">

我需要代替

<input type="submit" value="Create a new account">

知道可能出了什么问题吗?

【问题讨论】:

    标签: html .net asp.net-mvc razor resx


    【解决方案1】:

    您在 HTML 输入标签中缺少引号:

    <input type="submit" value="@ViewBag.Submit" />
    

    @ 符号将按原样打印出值,不带引号,因此您目前最终得到:

    <input type="submit" value=Create a new account>
    

    【讨论】:

      【解决方案2】:

      您需要将值双引号,以便将其视为文本

         <input type="submit" value="@ViewBag.Submit" />
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-09-10
        • 1970-01-01
        • 2019-02-05
        • 2014-09-28
        • 1970-01-01
        相关资源
        最近更新 更多