I have a Literal control (I also tried it with a label control).
This control should display a message in the appropiate language.
What have I done now:
in my resource files I have defined a key named: "ltrlMailError"
in each resource files I say in the appropiate language that there has been a mail problem.
Now in my code behind, when I detect that a mail error has occurred, I thought I could just assign a text to this Literal control like so:
ltrlStatus.Text =
"""<%$ Resources:lblMailError %>"""
OR like:
ltrlStatus.Text = "<%$ Resources:lblMailError %>"
But that doesnt work....(i've been playing around with the Mode attribute of the Literal control too, but still no luck....
How can I solve this localized error message problem?
Thanks!
please mark answers as 'Answered' and post back solutions when you figure stuff out that isnt in the post already.
You can't put markup in your codebehind. You'll have to use C# code if you want to assign it from resources. For this you use the
ResourceManager class. Just as so:
Wow! absolutely great! I knew those guys at MS would have thought of this ;)
But your link is no longer valid, I found the following two pages to be very helpfull:
Member
613 Points
2042 Posts
Localized error message
Apr 08, 2006 09:21 AM|Peter Smith|LINK
This control should display a message in the appropiate language.
What have I done now:
in my resource files I have defined a key named: "ltrlMailError"
in each resource files I say in the appropiate language that there has been a mail problem.
Now in my code behind, when I detect that a mail error has occurred, I thought I could just assign a text to this Literal control like so:
ltrlStatus.Text =
"""<%$ Resources:lblMailError %>"""OR like:
But that doesnt work....(i've been playing around with the Mode attribute of the Literal control too, but still no luck....ltrlStatus.Text = "<%$ Resources:lblMailError %>"
How can I solve this localized error message problem?
Thanks!
Member
190 Points
87 Posts
Re: Localized error message
Apr 10, 2006 09:06 PM|andersonimes|LINK
You can't put markup in your codebehind. You'll have to use C# code if you want to assign it from resources. For this you use the ResourceManager class. Just as so:
That's it. Good luck!Member
613 Points
2042 Posts
Re: Localized error message
Apr 11, 2006 02:08 PM|Peter Smith|LINK
But your link is no longer valid, I found the following two pages to be very helpfull:
http://samples.gotdotnet.com/quickstart/howto/doc/createresources.aspx
http://samples.gotdotnet.com/quickstart/aspplus/doc/resourcefiles.aspx
Thanks!