Control Naming and Referencing from Client Script code

The wwHoverPanel control uses a slightly unorthodox ASP.NET naming scheme in that it does not generate a container specific UniqueID and ClientID into the client code. Instead the control generates the plain ID for the client side control. Essentially the control overrides UniqueID and ClientID to return the plain ID to simplify access to the control and its client counterparts.

Both the wwHoverPanel and wwMethodCallback controls create a global client side variable with the same ID as the control but the variables serve different purposes in each scenario.

wwHoverPanel

For wwHoverPanel operation there's a global object with the same name as the control defined. So if you have wwHoverPanel Control with the name of LookupPanel a global called LookupPanel exists that is a client wwHoverPanel control. The instance is automatically defined and looks like this:

var LookupPanel = LookPanel_GetHoverPanel();

The _GetHoverPanel() function returns a configured instance of the wwHoverPanel client class that includes all the server control set settings. You can create a new instance if you chose or use the existing instance and then further customize it as needed:

var MyPanel = LookPanel_GetHoverPanel(); MyPanel.panelOpacity = .10; MyPanel.navigateDelay = 200; MyPanel.startCallback(null,"id=3232",null,OnErrorPage);

wwMethodCallback

The wwMethodCallback control generates a global proxy object with the same name as the control. The proxy contains matching methods of the methods exposed on the server. With the proxy defined you can then simply start firing away at the object from anywhere. Assuming you have a wwMethodCallback control called Callback and server method called HelloWorld marked with the [CallbackMethod] attribute you can simply call:

Callback.HelloWorld('Rick',HelloWorld_Callback,OnPageError);

If you have proxy generation turned off this automatic instance does not exist and you can easily create an instance with:

var MyCallback = Callback_GetCallback()

As with the wwHoverPanel control this creates a preconfigured new instance of the control with the settings configured on the server side control. You can then change the properties as needed and eventually call the callMethod() method to fire the request to the server.

var MyCallback = Callback_GetCallback() MyCallback.callMethod("HelloWorld",["Rick"],HelloWorldCallback,OnPageError);

Watch out for potential naming conflicts

Both controls override the UniqueId and ClientId properties, so you have to ensure you give these controls unique names, especially if you decide to use them inside of a list based naming container. This should be an unlikely occurrance since the control is likely page or control level, but it bears keeping in mind.


  Last Updated: 12/29/2007 | © West Wind Technologies, 2008