First, open menu "File->Add…," click "New
Website…" and select "ASP.NET AJAX-based Web Site" template to
create a sample website named AJAXServMenu.
Second, right-click the website and add reference to the
above newly-generated assembly.
Third, to use the server control AJAXServMenuCtrl in page "Default.aspx,"
we have to first register the control in the page by using the following Register
<%@ Register Assembly="AJAXServMenuLib" Namespace="AJAXServMenuLib" TagPrefix="ajax" %>
This directive references the assembly name (AJAXServMenuLib),
the namespace that the control resides in (AJAXServMenuLib), as well as the tag
prefix (ajax) that should be used to define the control in this page. Once
registered, this control can be used in the page just the same as any other
ASP.NET server control. What we merely need to do is define the tag prefix and
class name followed by all of the necessary properties in the Register
directive. In this case, the related code is shown below.
<ajax:AJAXServMenuCtrl ID="divAjaxMenu" runat="server" MenuTitle="Topics"
ServicePath="MenuService.asmx" ServiceMethod="GetMenuData" Width="500px" />
Once the page is called by an end user through a browser,
the necessary client-side script code used by control AJAXServMenuCtrl will
automatically be added to the rendered output by the ScriptManager control.
Now, just press F5 and watch what happens. Figure 5 corresponds to one of the run-time snapshots.
Figure 5 - One of the run-time snapshots for Sample
Author's Note: Here, I omit the
analysis of the generated HTML code on the browser, but I highly recommend
readers to examine it themselves to make clearer the mechanisms behind the