Monday, June 8, 2009

Web Resource but no Embedded Resource

I was having a major problem trying to get an embedded javascript file registered.
The issue started because I was trying to port over Raj Kaimal's ( ) GridView client side reordering extender to the Data Grid. Since both controls are very similar the work wasn't difficult, however I was getting hung up trying to stick the .js file in my backend dll.

Searching google it seemed as though a lot of people got hung up in this area. I finally stumbed on Lee's post which directed me to Damian's blog

While niether of those posts directly solved my issue, Damian gave me the idea of using a reflector to see what the .NET view of my dll looked like. From that and a little luck I discovered that the proper syntax was:
[assembly: System.Web.UI.WebResource("[default namespace].[folder].[file name].js", "text/javascript")]

then for the script reference:
new ScriptReference("[default namespace].[folder].[file name].js", "[assembly name]");

most people keep the default namespace and the assembly name the same which makes things simpler but fosters a lot of confusion as to what the various parameters are really looking for.

No comments:

Post a Comment

Please leave your thoughts, I love hearing what you got out of the post. Spam comments will be removed.