Using App_LocalResources in a DNN Module
Jul
20
Written by:
7/20/2011 3:56 PM
So as I'm sure anyone who has ever done custom ASP.Net development, occasionally I find myself needing to use Resource files. I've always thought they were a tremendous pain in the ass, but the concept is awesome. The concept being you can localize content without having to either a) create a new site or b) recompile the entire frigging thing.
In
DNN, it's a best practice that you include resource files so that your module can be easily configurable for multiple languages. Today, at the day job, I had a situation presented to me where using resource files would make a hell of a lot of sense. Unfortunately, I've
never had good luck with these stupid things, but I am a sadist when it comes to figuring out problems like this, and I decided to give it a shot.
Using Visual Studio 2010, I was able to get my project set up rather quickly. I set up my UI for the module, and then on a lark (and while I had the ASCX file open), I went to Tools > Generate Local Resource File.
It was awesome. My resource file was setup and looked great. Because I've had poor experiences before, I stripped out all of my default text and loaded up my module on a DNN 5.6.3, IIS 7, ASP.Net 4.0 web site. Lucky for me, my prior experience saved me from being disappointing me. Nothing showed up.
After spending an hour searching for an answer (and a trip to
Soulard Coffee Garden), I was resigned to doing this in a static fashion. But first I had to try one last thing. I downloaded a copy of the DotNetNuke Documents module because I
know it uses localized resource files. No dice. But that got me wondering, and I made one last
google query, which gave me an
answer two - three links below.
When I clicked "Generate Local Resources," Visual Studio added the property
meta:resourcekey="..." which I assumed was correct. Not so. Make sure when you're working on your module to use
resourcekey="..." instead. That'll pick up references in your App_LocalResources directory.
Cheers!