Page.RegisterClientScriptBlock Method (String, String)
Emits client-side script blocks to the response.
Assembly: System.Web (in System.Web.dll)
[ObsoleteAttribute("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 )
The client-side script is emitted just after the opening tag of the Page object's <form runat= server> element. Be sure to include opening and closing <script> elements around the script block string specified in the script parameter.
Because this method uses a key to identify the script block, the script block does not have to be emitted to the output stream each time it is requested by a different server control instance. Using a key also decreases the likelihood of different controls' script blocks interfering with each other.
Any script blocks with the same key parameter values are considered duplicates.
Remember to include HTML comment tags around your script so that it will not be rendered if the requesting browser does not support scripts.
Legacy Code Example
The following code example demonstrates the use of the IsClientScriptBlockRegistered method. If the ECMAScript in the code declaration block has not already been registered, as determined by IsClientScriptBlockRegistered, the call is made.method in conjunction with the Code snippet is not found. Confirm that the code snippet name 'System.Web.UI.Page.RegisterClientScriptBlock' is correct.
Available since 1.1