Skip navigation.

Too Much To DoAll recent postsIssues With Saving Unicode Pages in Visual Studio Put to Rest?

No Resource Expressions in Skins

In ASP.NET 2.0, skins and themes are a great way to give server controls a consistent look throughout a web app. It is rightfully suggested that skins contain control declarations with properties related to the layout and look-and-feel only. Behavioral attributes should not appear in skins.

Case in point: the other day I wanted to create a skin for the Wizard control and assign it “localized” text for the Previous, Next, Cancel and Finish buttons. I wanted these buttons initialized from a resource file and “translated” on the fly:

<asp:Wizard runat="server" 
  FinishCompleteButtonText="<%$ Resources: WebResources,Foo_Bar%>">
</asp:Wizard>

It appears, no code blocks (<%…%>) are allowed in skins. I don’t know if resource expressions can be considered code blocks per se, but the parser treats them this way. However, this much works:

<asp:Wizard runat="server" FinishCompleteButtonText="Foo bar">
</asp:Wizard>

I think button text is as presentational an aspect as it can get, and—in my opinion—restriction on resource expressions should be relaxed. Otherwise, the only way to give the Wizard a consistent look is to subclass from it and use the derived class in its stead. Not a bad way out, but it’s a different ball game.

By the way, there’s a subtle issue with maintaining control state in subclassed controls. But this is a subject for another post.

P.S. I will be presenting on the topic of localization at the NJ Code Camp this coming week-end.

Comments

Comment permalink 1 Jørn Schou-Rode |
Did you look into the new "implicit localization" framework in ASP.NET 2.0? Without having testet this with skins, but the meta:resourcekey attribute seems to handle theese types of localization well in most cases. http://www.theserverside.net/tt/articles/showarticle.tss?id=LocalizationPractices
Comment permalink 2 Milan Negovan |
For implicit localization you'd need a control ID, and this is something you do not put in skin files.
Comment permalink 3 Milan Negovan |
I take it back. I confused it with resourcekey. Still, I prefer to stay away from local resource files. The thought of dragging a resource file for each page makes me uncomfortable.
Comment permalink 4 tec-goblin |
I tried this with localized resources, it seemed to ignore the meta:resourcekey
Comment permalink 5 Per Zimmerman |
meta:resourcekey is ignored in skin-files. That makes skin-files useless when you working with localized pages.

Emails and Notifications

Would you like to be notified when somebody responds to this post?  Would you like to have these comments emailed to you?

TrackBacks

Sorry, TrackBacks are not allowed.

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):