【问题标题】:Save text and link in asp.net mvc resource file - resource.aspx.resx在 asp.net mvc 资源文件中保存文本和链接 - resource.aspx.resx
【发布时间】:2011-04-07 21:08:22
【问题描述】:

我有一个带有 html 的句子。操作链接:

<b>Please enter your username and password.
        <%= Html.ActionLink("Register", "Register", null, new { @id = "logOnLinkRegister" })%>
        if you don't have an account. </b>

如何将其保存在resource.aspx.resx 文件中? 它在 asp.net mvc web 项目中。

【问题讨论】:

    标签: asp.net-mvc resources html.actionlink


    【解决方案1】:

    首先,将值添加到您的资源文件中,Visual Studio 会直观地执行此操作,因此添加

    Name: Register
    Value: Register
    
    Name: IfYouDontHaveAnAccount
    Value: if you don't have an account
    

    确保您在资源文件中设置了以下设置...

    访问修饰符“公共”

    这将自动生成类。

    现在您可以直接在视图中使用资源...假设“YourProjectName”将是您的实际项目名称,并且您在名为“Resources”的文件夹中弹出了一个名为“Labels”的资源文件

    <%@ Import Namespace="YourProjectname.Resources" %>
    
    <strong>Please enter your username and password.
    <%= Html.ActionLink(Labels.Register, "Register", null, 
        new { @id = "logOnLinkRegister" })%>
    Labels.IfYouDontHaveAnAccount. </strong>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-24
      • 1970-01-01
      • 2015-11-14
      • 1970-01-01
      相关资源
      最近更新 更多