Skip to main content
.NET Framework Class Library
ClientScriptManagerRegisterClientScriptInclude Method (String, String)

Registers the client script with the Page object using a key and a URL, which enables the script to be called from the client.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)
Syntax
Public Sub RegisterClientScriptInclude ( _
	key As [%$TOPIC/2552td66_en-us_VS_110_2_0_0_0_0%], _
	url As [%$TOPIC/2552td66_en-us_VS_110_2_0_0_0_1%] _
)
public void RegisterClientScriptInclude(
	[%$TOPIC/2552td66_en-us_VS_110_2_0_1_0_0%] key,
	[%$TOPIC/2552td66_en-us_VS_110_2_0_1_0_1%] url
)
public:
void RegisterClientScriptInclude(
	[%$TOPIC/2552td66_en-us_VS_110_2_0_2_0_0%]^ key, 
	[%$TOPIC/2552td66_en-us_VS_110_2_0_2_0_1%]^ url
)
member RegisterClientScriptInclude : 
        key:[%$TOPIC/2552td66_en-us_VS_110_2_0_3_0_0%] * 
        url:[%$TOPIC/2552td66_en-us_VS_110_2_0_3_0_1%] -> unit

Parameters

key
Type: SystemString

The key of the client script include to register.

url
Type: SystemString

The URL of the client script include to register.

Remarks

A client script include is uniquely identified by its key and its type. Scripts with the same key and type are considered duplicates. Only one script with a given type and key pair can be registered with the page. Attempting to register a script that is already registered does not create a duplicate of the script.

Call the IsClientScriptIncludeRegistered method to determine whether a client script include with a given key and type pair is already registered and avoid unnecessarily attempting to add the script.

NoteNote

To resolve the client URL, use the ResolveClientUrl method. This method uses the context of the URL on which it is called to resolve the path.

This overload of the RegisterClientScriptInclude method calls the overload that takes a key, a URL, and a type parameter.

The method adds a script block at the top of the rendered page.

Examples

For related information, including syntax, usage, and an example, see RegisterClientScriptInclude.

Version Information

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0
Platforms

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.