Asp.net 显式本地化问题
我在 ASP.net 中的本地化方面遇到一些问题。 我已经生成了资源并通过变量绑定了文本属性。 在源文件中。
<asp:Label ID="Label1" runat="server" Text='<%# Eval("name") %>' meta:resourcekey="Label1Resource1"></asp:Label>
后面的代码
protected string name;
protected void Page_Load(object sender, EventArgs e)
{
name = "Hello World";
}
上面的事情很简单,但是当我运行项目时。 我得到
Parser Error
描述:解析服务此请求所需的资源时发生错误。请查看以下特定解析错误详细信息并适当修改您的源文件。
解析器错误消息:“System.Web.UI.WebControls.Label”上的属性“Text”上不能有多个绑定。确保此属性不是通过隐式表达式绑定的,例如使用 meta:resourcekey。
源错误:
上面只是我在项目中遇到的一个例子。
请帮助我如何同时进行本地化和绑定。
I have some problem with the Localization in ASP.net.
I have generated the resources and binding the text property by an variable.
In the source file.
<asp:Label ID="Label1" runat="server" Text='<%# Eval("name") %>' meta:resourcekey="Label1Resource1"></asp:Label>
code behind
protected string name;
protected void Page_Load(object sender, EventArgs e)
{
name = "Hello World";
}
The above things are simple but when I run the project.
I got
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Cannot have more than one binding on property 'Text' on 'System.Web.UI.WebControls.Label'. Ensure that this property is not bound through an implicit expression, for example, using meta:resourcekey.
Source Error:
The above is just an example what I am facing in my project.
Please Help me how can I make localization and binding both at the same time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我找到的解决方案是在标签之间制作数据。
但这
也导致了另一个问题。
如果我想在后面的代码中访问该标签的值该怎么办?
What Solution I found is Making the data in between the tags.
like
But this also leads to another problem.
What if I want to access the value of that label inside code behind.
您一次只能对页面事件使用一个绑定。
如果您想同时使用这两种绑定,那么它必须在不同的事件中使用。
You can use only one binding at a time on Page events.
If you want to use both binding then it must besides in different events.
避免将 Text 属性放置在标记中,因为它已经绑定到资源文件中的本地化文本,只需调用 Label1.Text = "hello world"。
Avoid placing the Text attribute in the markup, as it's already bound to the localized text in the resource file, and just call Label1.Text = "hello world".