1, OnClientClick (VS2003 does not support this method)
<ID= "button" runat= "Server" Text= "button" OnClientClick = "Client_click ()" OnClick = "Button1_Click" />
Client_click () is a method of JavaScript.
2, Backstage add Button.Attributes.Add ("onclick", "Return Client_click ()");
"Client_click ()" is a foreground method that can be replaced by a generic script such as: Retrun confirm (' OK to delete? ‘)
3. Write script with Response.Write method
For example, after you click the button, the database is finished, the display is finished, you can write in the last place to call
Response.Write ("<script type= ' Text/javascript ' >alert ();</script>");
One drawback of this approach is that you cannot invoke a custom function in a script file, only call an intrinsic function, and call a custom function to write the function definition only in Response.Write.
such as Response.Write ("<script type= ' Text/javascript ' >function myfun () {...} </script> ");
4. Add scripts dynamically with the ClientScript class
Use the following: Add code where you want to invoke a JavaScript script function, and be sure that Myfun has already been defined in the script file.
" MyScript " " <script>myfun ();</script> "
This method is more convenient than Response.Write, you can directly invoke the custom function in the script file.
StringBuilder SB =New StringBuilder (); sb. Append ( "<script language= ' JavaScript ' > "); Sb. Append ( "button2_onclick (' " "); Sb. Append ( "</script> "); Clientscript.registerstartupscript (this. GetType (), "loadpicscript ", sb. ToString ());
JavaScript's execution foreground function