System. Web. UI. scriptmanager. registerstartupscript to replace page. clientscript. registerstartupscript
Function prototype:
System. Web. UI. scriptmanager. registerstartupscript (contrl control, type, string key, string script, bool addscripttags );
Parameters:
Control ----------------- to register the Control ID of this JavaScript statement, as shown in the following example:
Type -------------------- this parameter is the type of the registered script block control, that is, the updatepanel type. You can use this. GetType () directly.
Key --------------------- indicates the name of the cirpt statement to be executed.
Script ------------------ JavaScript statement
When addscripttags is set to true, you do not need to write JavaScript labels for the script parameter on the front. If it is set to false, you need to add the <script language = 'javascript '> </SCRIPT> label for the script parameter.
Note: One more control parameter is required. If the control is in updatepanel, the operation is completed. If the control is not in updatepanel, this step is not allowed.
For example:
System. web. UI. scriptmanager. registerstartupscript (btntestthis. getType (), "test", "alert (''test''); window. close (); ", true );