Introduction
Having developed an Atlas composite social security control, I wanted to change the root namespace from the default (<Project Name>) to the standard followed at my company. I thought it would be simple enough; I was in for a big surprise. Basically, I opened the project properties and replaced the Root namespace from “AmericanSSN” (this was my project name) to “AO.Web.UI.AtlasControls”. I recompiled the project, included it in the toolbox, and dropped the composite control on an ASPX page, the control rendered fine at design time. When the page was loading at runtime, I got the “Unrecognized tag” error for “americanssn:AmericanSSNBehavior”. Looking at the rendered HTML, I found that under the XML-script section generated by the extender class, the Page
tag and Behavior
were rendered as:
<page ….
xmlns:americanssn="americanssn">
<behaviors>
<americanssn:AmericanSSNBehavior MyProperty=""
PageRequestManagerID="_PageRequestManager"
id="AmericanSSNControl1_SSNProperties" />
</behaviors>
Next, I looked at the generated assembly using ILDASM. At the very end of the MANIFEST
section was the following entry to bundle the JavaScript resource into the assembly:
.mresource public AO.Web.UI.AtlasControls.AmericanSSNBehavior.js
{
}
Since I had changed the Root namespace, I had to now change the extender file so that it renders the following:
<page ….
xmlns:ao.web.ui.atlascontrols="ao.web.ui.atlascontrols">
<behaviors>
<ao.web.ui.atlascontrols:AmericanSSNBehavior MyProperty=""
PageRequestManagerID="_PageRequestManager"
id="AmericanSSNControl1_SSNProperties" />
</behaviors>
I also had to change the JavaScript file. The changes required are explained in the following three steps.
Step 1.
Modifications to project properties: Click on project properties and change the root namespace from
<Project Name> to
AO.Web.UI.AtlasControls.
Step 2.
Modifications to the extender file (AmericanSSNExtender.vb):
Modify the “Assembly Resource Attribute” region, click on the + sign to open the region, and change the namespace qualifier of the JavaScript file from
<Project Name> to the root namespace. Modify the
ClientScriptResource
class attribute tag, change the prefix parameter from
<Project Name> to the root namespace, and change the namespace qualifier of the JavaScript file <project name="">to the root namespace.
The sections marked in Red were replaced with those marked in Blue:
The above was changed to:
Step 3.
Modifications to the behavior file (AmericanSSNBehavior.vb):
The sections marked in Red were replaced with those marked in Blue at different places in the JavaScript file:
The above was changed to:
The above was changed to:
The above was changed to: