ScriptManager::RegisterClientScriptInclude Method (Control^, Type^, String^, String^)


Registers a client script file with the ScriptManager control for use with a control that is inside an UpdatePanel control, and then adds a script file reference to the page.

Namespace:   System.Web.UI
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

static void RegisterClientScriptInclude(
	Control^ control,
	Type^ type,
	String^ key,
	String^ url


Type: System.Web.UI::Control^

The control that is registering the client script file.

Type: System::Type^

The type of the client script file. This parameter is usually specified by using the typeof operator (C#) or the GetType operator (Visual Basic) to retrieve the type of the control that is registering the script.

Type: System::String^

A unique identifier for the script file.

Type: System::String^

The URL of the script file.

Exception Condition

The client script file type is null.

- or -

The control that is registering the script file is null.


The control that is registering the script file is not in the page's control tree.

- or -

url is null.

- or -

url is empty.

You use the RegisterClientScriptInclude method to register a client script file for a page or part of a page that is participating in partial-page updates. Client script files that are registered by using this method are sent to the page only when the control represents a control that is inside an UpdatePanel control that is being updated. To register a script file every time that an asynchronous postback occurs, use the RegisterClientScriptInclude(Page^, Type^, String^, String^) overload of this method.

If you want to register a script block that does not pertain to partial-page updates, and if you want to register the script block only one time during initial page rendering, use the RegisterClientScriptBlock method of the ClientScriptManager class. You can get a reference to the ClientScriptManager object from the ClientScript property of the page.

The RegisterClientScriptInclude method registers a client script file on the page by rendering a script element whose opening tag contains a src attribute. The url parameter is used to set the src attribute. To resolve URLs, use the ResolveClientUrl method. This method uses the context of the URL it is called for to resolve the path.

Both the RegisterClientScriptInclude and RegisterClientScriptResource methods render script files to the browser. If a script with the same type and key (for a script file) or the same type and resource name (for an embedded resource) is already rendered, the script is not rendered again.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 3.5
Return to top