c# - best practices / tips for storing html tags in resource files -
I have the following condition: Assume that I have to display the data in the following format.
I'm 20 years old
. I need the number 20 in bold.
I'm bringing this string from a resource file like this
string.format (HttpContext.GetGlobalResourceObject ("ResourceFile", "Key"), age) ;
Do I have to type the & lt; B & gt;
and & lt; / B & gt;
should consider adding tags? Is this considered a "best practice"? Can anyone get useful links on localization?
Do not store tags that change visual style in resources
Code / For the purpose of separating the data / presentation, I recommend that you do not store the tags in your resource file. It will make it difficult to maintain ASPX / SSC files as well as tag in resources and even in DB
You should isolate concerns following the pattern And keep things separate.
Key value "UserAge" "It looks like you are old year {0}."
Some loose restrictions may help
but when some nested markup is used, the most safe The thing to do this is that the tag can not provide any style copies in your case I & lt; Span & gt; I'm using the
tag more (because it's an inline style and what it really is you want). CSS will define visual presentation at the end.
Key value "UserAge" "It seems that you are
But you should understand implications. Doing it this way can still be worse without tagging anyone. Imagine what happens when you change your presentation layer, let's say for a service or a Windows desktop app. In this context, & lt; Span & gt;
No meaning exists, they can be left, but why would you keep them in the first place?
Comments
Post a Comment