Επεξεργασία

Κοινή χρήση μέσω


IExtenderControl Interface

Definition

Defines the behavior for an extender control.

public interface class IExtenderControl
public interface IExtenderControl
type IExtenderControl = interface
Public Interface IExtenderControl
Derived

Remarks

Extender controls that derive from the ExtenderControl class require a ScriptManager control to be on the page. The ExtenderControl base class performs an explicit test to make sure that a ScriptManager control exists on the page.

However, if you want to create extender controls and the page does not contain an ScriptManager control, you can create a class that implements the IExtenderControl interface directly. Additionally, if you are creating a class that derives from Control or you are extending an existing control that derives from Control, you can implement the IExtenderControl interface to support client functionality.

The IExtenderControl interface registers the script libraries for a control by calling the GetScriptReferences method, and it registers ScriptDescriptor objects by calling the GetScriptDescriptors method. The GetScriptDescriptors method returns an IEnumerable list of ScriptDescriptor objects.

Note

If you extend an existing control type that is derived from the WebControl class, implement the IScriptControl interface.

To create an extender control by implementing IExtenderControl, you do the following:

  • Write code for the control's OnInit event to detect and use the ScriptManager control if it is available on the page.

  • If the ScriptManager is not available on the page, provide alternative means to register required scripts by calling static methods of the ScriptManager class.

  • Provide protected virtual members for IExtenderControl members.

  • Provide instance script as a script block that you register with the ScriptManager control. You must do this during the control's PreRender, PreRenderComplete, or Render events.

  • Register the script descriptors during the control's Render event.

Note

If the page contains an UpdatePanel control, the page must contain a ScriptManager control. You must implement the IExtenderControl interface only when the page does not contain a ScriptManager control.

Methods

GetScriptDescriptors(Control)

Registers the ScriptDescriptor objects for the control and returns an object that contains the ScriptDescriptor objects for the control.

GetScriptReferences()

Registers the script libraries for the control and returns an enumeration of ECMAScript (JavaScript) files that have been registered as embedded resources.

Applies to

See also