1. This method can only call simple JS Code. User-defined functions cannot be called.
Copy codeThe Code is as follows:
String jss = "<script language = 'javascript 'Type = 'text/javascript '> alert ('hello') </script> ";
Response. Write (jss );
2. General methods. Mya () is a UDF defined in the front-end code.
(1)
Copy codeThe Code is as follows:
String sl = "<script language = 'javascript 'Type = 'text/javascript '> mya ('hes') </script> ";
Page. ClientScript. RegisterStartupScript (ClientScript. GetType (), "mya", sl );
(2)
Copy codeThe Code is as follows:
String sl = "<script language = 'javascript 'Type = 'text/javascript '> mya ('hes') </script> ";
Page. RegisterStartupScript ("mya", sl); // The RegisterStartupScript method of the Page is outdated. Use the RegisterStartupScript method of ClientScript.
Page. ClientScript attributes
Obtain the ClientScriptManager object used to manage scripts, register scripts, and add scripts to pages. // Call this property to return a ClientScriptManager object.
Note:
Use the ClientScript attribute to obtain a ClientScriptManager object that can be used to manage scripts, register scripts, and add scripts to webpages. For more information, see ClientScriptManager class.
The ClientScriptManager class is a new class in ASP. NET 2.0. It replaces the Page class method that has been denied for script management.
ClientScriptManager class
Define a method for managing client scripts in a Web application.
ClientScriptManager. RegisterStartupScript method // dynamically Add a script to the client
Register the startup script with the Page object.