Language

Page.RegisterClientScriptBlock(String, String) Method

Definition

Caution

The recommended alternative is ClientScript.RegisterClientScriptBlock(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202

Emits client-side script blocks to the response.

public:
 virtual void RegisterClientScriptBlock(System::String ^ key, System::String ^ script);
public virtual void RegisterClientScriptBlock(string key, string script);
[System.Obsolete("The recommended alternative is ClientScript.RegisterClientScriptBlock(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202")]
public virtual void RegisterClientScriptBlock(string key, string script);
abstract member RegisterClientScriptBlock : string * string -> unit
override this.RegisterClientScriptBlock : string * string -> unit
[]
abstract member RegisterClientScriptBlock : string * string -> unit
override this.RegisterClientScriptBlock : string * string -> unit
Public Overridable Sub RegisterClientScriptBlock (key As String, script As String)

Parameters

key
String

Unique key that identifies a script block.

script
String

Content of script that is sent to the client.

Attributes

Examples

The following code example demonstrates the use of the RegisterClientScriptBlock method in conjunction with the IsClientScriptBlockRegistered method. If the ECMAScript in the code declaration block has not already been registered, as determined by IsClientScriptBlockRegistered, the RegisterClientScriptBlock call is made.

<%@ Page Language="C#"%>



  
    RegisterClientScriptBlock Example
  
  
     
<%@ Page Language="VB"  %>





  
    RegisterClientScriptBlock Example
  
  
     

Remarks

The client-side script is emitted just after the opening tag of the Page object's

element. Be sure to include opening and closing