开发者

Validation controls error message from Resource file and parameterized

开发者 https://www.devze.com 2023-01-01 11:21 出处:网络
I would like to get validation messages for validation controls from resource files. I know I can do that easily by following code snippet.

I would like to get validation messages for validation controls from resource files. I know I can do that easily by following code snippet.

<%$ Resources:[filename prefix,]resource-key %>

or

<asp:Label ID="Label1" runat="server" meta:resourcekey="resource-key-prefix" />

But I would 开发者_高级运维also like to parameterized it.

e.g. Above Resource Expression will give me message like "Fill Information.". What I have in resource file is "Fill {0} Information." which should show end user message like "Fill Address Information.".


So basically you want to have a localized Formatstring.

You can access the resource file from the codebehind, perform a String.Format and pass the value on to a control.

E.g.

myLabel.Text = string.Format(ProjectnameSpace.Resources.xxy, VALUE);

Try intellisense to get the full path of the property, I don't have visual studio here atm

0

精彩评论

暂无评论...
验证码 换一张
取 消