This documentation is archived and is not being maintained.

ClientScriptManager.RegisterClientScriptBlock Method (Type, String, String)

Registers the client script with the Page object using a type, key, and script literal.

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

public void RegisterClientScriptBlock (
	Type type,
	string key,
	string script
)
public void RegisterClientScriptBlock (
	Type type, 
	String key, 
	String script
)
public function RegisterClientScriptBlock (
	type : Type, 
	key : String, 
	script : String
)
Not applicable.

Parameters

type

The type of the client script to register.

key

The key of the client script to register.

script

The client script literal to register.

A client script 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 IsClientScriptBlockRegistered method to determine whether a client script with a given key and type pair is already registered and avoid unnecessarily attempting to add the script.

In this overload of the RegisterClientScriptBlock method, you must make sure that the script provided in the script parameter is wrapped in a <script> element block.

The RegisterClientScriptBlock method adds a script block to the top of the rendered page. The script blocks are not guaranteed to be output in the order they are registered. If the order of the script blocks is important, use a StringBuilder object to gather the scripts together in a single string, and then register them all in a single client script block.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Show: