The ASP.NET Ajax Control Toolkit has a hate-on for namespaces, let me tell you. Their sample works slicker'n a greased hog when you use nice project names like "DisableButton" or "AlertBox". But use a name like "Suvius.DynamicFamilyTreeSorter" and you're in for a world of hurt.

Side note: Call me old-fashioned, but I like having the namespace in my project name. Saves me having to muck with assembly names in the project properties and makes things obvious when I'm staring at a twenty-project solution with four projects named DataAccessLayer. Plus it fosters creativity in naming if the project contains classes from different namespaces.

So what's a hillbilly to do if they like seeing they're comp'ny name embedded in the control project name? Let's assume you have just created an AJAX Control project with the name "Suvius.DynamicFamilyTreeSorter". Your project will contain three files:

  • Suvius.DynamicFamilyTreeSorterBehavior.js
  • Suvius.DynamicFamilyTreeSorterDesigner.cs
  • Suvius.DynamicFamilyTreeSorterExtender.cs

The first task is to rename each of these files, removing "Suvius." from the beginning of each. After that, here are the steps for the contents of each file:

DynamicFamilyTreeSorterBehavior.js

  • First non-commented line of code: Change the namespace to Suvius
  • Last non-commented line of code: Change the first argument in the call to registerClass to Suvius.DynamicFamilyTreeSorter (i.e. removing the trailing ".Suvius")

DynamicFamilyTreeSorterDesigner.cs

  • Remove "Suvius." from the name of the class
  • Remove "Suvius." from the generic part of the ExtenderControlBaseDesigner<> declaration. This isn't totally necessary but helps keeps things clear

DynamicFamilyTreeSorterExtender.cs

  • Remove "Suvius." from the name of the class
  • Remove "Suvius." from the [Designer] attribute
  • In the [assembly: WebResource] declaration, remove the *second* "Suvius.". I.E. It should read
    [assembly: WebResource("Suvius.DynamicFamilyTreeSorter.
    DynamicFamilyTreeSorterBehavior.js"
    , "text/javascript")]

  • In the [ClientScriptResource] attribute, remove the *second* "Suvius." from *both* arguments, similar to the previous step

For the longest time, I was getting a run-time error: Assemby 'yadda yadda' contains a Web resource with name 'Suvius.DynamicFamilyTreeSorter.DynamicFamilyTreeSorterBehavior', but does not contain an embedded resource with name 'Suvius.DynamicFamilyTreeSorter.DynamicFamilyTreeSorterBehaviour.js'. This after I had performed all the steps above. Except renaming the files in the first place.

So it would appear that WebResource locates files based on their location (replacing slashes with dots). Lesson learned. Or at least documented.

*EDIT*

One more step: In DynamicFamilyTreeSorterBehavior.js, replace all instances of Suvius.DynamicFamilyTreeSorterBehavior.Suvius with Suvius.DynamicFamilyTreeSorterBehavior.

Kyle the Assembled