获取文本从资源文件中asp.net 4 [英] Getting text from the Resource file in asp.net 4

查看:138
本文介绍了获取文本从资源文件中asp.net 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net网页,其中包含一个标签,现在我想从localresource文件中的标签的文本属性,我有一个的.resx App_LocalResources文件文件夹,其中包含名称为 UserNameLabel.Text 和值用户名文件现在在我的 ASPX 文件我使用标签控制这样的

i have an asp.net webpage, which contains a label, now i want to get the text property of the label from the localresource file, i have a .resx file under App_LocalResources folder, which contains Name as UserNameLabel.Text and Value as User Name now in my aspx file i am using Label control like this

< ASP:标签ID =UserNameLabel=服务器的ResourceKey =UserNameLabel>< / ASP:标签>

但我不能得到标签的文本,任何人都可以告诉我正确的方式从资源文件中添加文本属性

but i cannot get the text on the Label, can anyone tell me the correct way to add the Text Property from resource file

推荐答案

首先,您需要创建web项目中适当的结构。在这种情况下,我将使用Default.aspx的:

First you need to create appropriate structure inside web project. In this case I will be using Default.aspx:

采取通知我把里面App_LocalResources文件为Default.aspx.resx文件。

Take notice I have placed Default.aspx.resx file inside App_LocalResources.

下一步里面输入为Default.aspx.resx新项目是这样的:

Next enter new item inside Default.aspx.resx like this:

重要的是你需要设置Text属性(UserNameLabel.Text)

The important thing is you need to set Text property (UserNameLabel.Text)

和终于在这里是ASPX code:

And finally here is aspx code:

<asp:Label ID="UserNameLabel" runat="server" meta:resourcekey="UserNameLabel"></asp:Label>

我用元:获取ResourceKey链接到相应的资源键

I have used meta:resourcekey to link to appropriate resource key.

这篇关于获取文本从资源文件中asp.net 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆