Skip navigation.

Usability Blooper: Dollar, You Ain't HelpingAll recent postsHow Does MS AJAX Manage to Crash Firefox?

Extender Control Just Won't Pick Up Localization

Imagine my surprise when, having gone through the AJAX localization tutorial and this MSDN article up, down and sideways, I couldn’t get my extender control to see resource strings on the client!

Here’s the extender skeleton:

[assembly: WebResource (
    "[blah].js",
    "text/javascript")]

[assembly: ScriptResource (
    "[blah].js", 
    "[blah recources]", 
    "ClientResources"]

namespace MyControls
{
 public class MyExtender : ExtenderControl
 {
  // Lots of stuff skipped
  protected 
      override IEnumerable<ScriptReference> GetScriptReferences()
  {
   yield return new ScriptReference (
       Page.ClientScript.GetWebResourceUrl (
                 typeof (MyExtender), "[blah].js")
    );
  }
 }
}

I don’t remember why I chose GetWebResourceUrl, but that’s precisely where the problem lies. Change the line to this and everything magically works:

yield return new ScriptReference ("[blah].js",
                        this.GetType ().Assembly.FullName);

Gotta love obscure edge-cases.

Comments

No comments yet

Emails and Notifications

Would you like to be notified when somebody responds to this post? 

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):