在 asp.net mvc 资源文件中保存文本和链接 - resources.aspx.resx

发布于 2024-09-17 18:18:38 字数 327 浏览 3 评论 0原文

我有一个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 项目中。

i have a sentence with html. action link:

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

how can i save it in resource.aspx.resx file?
it is in the asp.net mvc web project.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绿光 2024-09-24 18:18:38

首先,将值添加到您的资源文件中,Visual Studio 会以可视方式执行此操作,因此请添加

Name: Register
Value: Register

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

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

访问修饰符“Public”

然后这将自动生成该类。

现在您可以直接在视图中使用资源...假设“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>

Firstly, add the value to your resource file, Visual Studio does this visually, so add

Name: Register
Value: Register

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

Make sure you set up the following setting on your resource file...

Access Modifier "Public"

This will then generate the class automatically.

Now you can use the resources directly in your views... It is assumed that "YourProjectName" would be your actual project name and that you've popped a resource file called "Labels" in a folder called "Resources"

<%@ Import Namespace="YourProjectname.Resources" %>

<strong>Please enter your username and password.
<%= Html.ActionLink(Labels.Register, "Register", null, 
    new { @id = "logOnLinkRegister" })%>
Labels.IfYouDontHaveAnAccount. </strong>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文