First: Call using the Attributes property in the normal add control
For example, normal buttons like the general: Button1.Attributes.Add ("onclick", "myfun ();");
This method is only valid if it is added in onload or in the initialization process similar to onload. The script function is executed first, and the execution order cannot be changed.
Second: Call using the Response.Write method
For example, as we will often use to the Response.Write ("<scripttype= ' Text/javascript ' >alert (" XXX ");</script>");
However, there is a flaw in this approach, that is, you cannot invoke a custom function in a script file, only the intrinsic function can be called.
A specific call to a custom function can only be written on the Response.Write function definition, such as
Response.Write ("<script type= ' Text/javascript ' >functionmyfun () {}</script>");
The third type: using the ClientScript class
For example, to invoke the Myfun (parameter) function in a JS file, be sure that Myfun has already been defined in the script file.
can be used Clientscript.registerstartupscript (Clientscript.gettype (), "MyScript", "<script>myfun (' parameters '); </script > ") method.
This method is more convenient than Response.Write, and you can invoke the custom function directly in the script file.