2010-09-03 99 views
1

我有一个句子与html。操作链接:保存文本和链接在asp.net mvc资源文件 - resource.aspx.resx

<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项目中。

回答

0

首先,价值添加到您的资源文件时,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>