The HoverPanel and AjaxMethodCallback control use a slightly unorthodox ASP.NET naming scheme in that it does not generate a container specific UniqueID and ClientID into the client code by default. 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. You can override this behavior with the OverrideClientID property which by default is to true. Set to false the controls continue to use standard naming container ClientID and UniqueID values.
Both the HoverPanel and AjaxMethodCallback controls create a global client side variable with the same ID as the control but the variables serve different purposes in each scenario.
For HoverPanel operation there's a global object with the same name as the control defined. So if you have HoverPanel Control with the name of LookupPanel a global called LookupPanel exists that is a client HoverPanel 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);
The AjaxMethodCallback 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:
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 HoverPanel 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.
If you're using these controls and are dynamically adding them as part of other custom controls it's recommended that you prefix the control names with the parent control's ID to ensure uniqueness.
Comment or report problem with topic