We often use some JavaS cript scripts when conducting ASP.NET development, such as Private Void Button1_Click (Object Sender, System.EventArgs E) {response.write (" Alert) 'Ok'); s cript> ");} It is often written for repeated writing. If we can make a corresponding function, you can use it directly. Many people have some of their own JavaS Cript functions, but most of them are such: /// Alert ('" str_message "); s cript>");}}, but when used, each time To inherit this class, it is still a bit trouble. If the function is a static function, the class is a static class, we can use it if we are inherited. But what do we write? Take a look at this code #Region Public Static Void MessageBox (Page Page, String Msg) / / / / / / / Bounce Dialog / / / / / The pointer of the current page is generally this /// message public static void MessageBox Page Page, String MSG) {StringBuilder strscript = new stringbuilder (); strscript.Append ("); strscript.append (" Alert ('" msg "); "); STRScript.Append (" s cript>"); if (! Page.isstartupscriptregistered ("MessageBox")) {page.registerStartupScript ("MessageBox", strscript.tostring ());}} #ENDREGION This kind of Convenient to use a lot of JS scripts. PS: Actually, many common methods can be written in a static function. There are even more examples there to be given as a reference.