best practices / tips for storing html tags in resource files
asp.net-mvc, c#, html, resources
Solution
Don't store tags that change visual style in resources
For code/data/presentation separation purposes I suggest you don't store tags in your resource file. It will make it harder to maintain (by having tags in aspx/ascx files as well as in resources and maybe even in the DB)
You should follow separation of concerns pattern and keep things separated.
Key Value
"UserAge" "It seems you are {0} year(s) old."
Some loose restrictions may help But when using some nested markup the most safe thing to do is having tags that don't provide any styling per se. In your case I'd use `<span>` tag at most (because it's an inline style and that's exactly what you need). CSS would define it's visual representaion in the end.
Key Value
"UserAge" "It seems you are <span>{0}</span> year(s) old."
But you should understand the implications. Doing it this way may still be worse than having no tags at all. Imagine what happens when you change your presentation layer. Let's say to a Service or a Windows desktop app. tags like `<span>` present no meaning in this context. They can be omitted, but why would you put them in in the first place then.
Problem
I have the following situation: assume I have to display the data in the following format. `I am 20 years old`. I need the number 20 to be in bold. I'm fetching this string from a resource file like this ``` string.Format(HttpContext.GetGlobalResourceObject("ResourceFile","Key"),age); ``` Should I consider adding the tags `<b>` and `</b>` within the resource file? Is that considered a "best practice"? Could anyone provide useful links on localization as well?