This documentation is archived and is not being maintained.

ClientScriptManager::RegisterClientScriptResource Method

Registers the client script resource with the Page object using a type and a resource name.

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

public:
void RegisterClientScriptResource(
	Type^ type, 
	String^ resourceName
)

Parameters

type
Type: System::Type
The type of the client script resource to register.
resourceName
Type: System::String
The name of the client script resource to register.

ExceptionCondition
ArgumentNullException

The client resource type is nullptr.

ArgumentNullException

The client resource name is nullptr.

- or -

The client resource name has a length of zero.

The RegisterClientScriptResource method is used when accessing compiled-in resources from assemblies through the WebResource.axd HTTP handler. The RegisterClientScriptResource method registers the script with the Page object and prevents duplicate scripts. This method wraps the contents of the resource URL with a <script> element block.

The following code example demonstrates the use of the RegisterClientScriptResource method.

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

The following code example demonstrates how to programmatically apply the WebResourceAttribute metadata attribute to mark the assembly for the resources that will be served.

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

This example requires a JavaScript file named Script_include.js, with the following contents:

function DoClick() {Form1.Message.value='Text from resource script.'}

Compile the Script_include.js file as a resource in the Samples.AspNet.CS.Controls assembly that contains the ClientScriptResourceLabel class.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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