Source. Library. Web. js. Alert

Source: Internet
Author: User
/*** <P> Description: (alert) </P> * <p> @ version 1.0.0 </P> * <p> modifaction :( date-version-author-description) </P> * <p> ------------------------------------------------------------------------ </P> */using system; using system. collections. generic; using system. LINQ; using system. text; using system. web; using system. web. ui; namespace source. library. web. JS {public class alert {# region uses httpcontext. current. response pop-up dialog box /// <summary> /// webpage message dialog box /// </Summary> /// <Param name = "message"> Message Text to be displayed </ param> Public static void httpcontextalert (string message) {httpcontext. current. response. write ("<script language = 'javascript 'Type = 'text/JavaScript '> alert ('" + message + "') </SCRIPT>"); httpcontext. current. response. write ("<SCRIPT> history. go (-1) </SCRIPT> "); httpcontext. current. response. end ();} /// <summary> /// webpage message dialog box /// </Summary> /// <Param name = "message"> Message Text to be displayed </param>/ // <Param name = "src"> Click OK to go to the page </param> Public static void httpcontextalert (string message, string SRC) {httpcontext. current. response. write ("<script language = 'javascript 'Type = 'text/JavaScript '> alert ('" + message + "'); location. href = '"+ SRC +"' </SCRIPT> "); httpcontext. current. response. end ();} /// <summary> /// webpage message dialog box /// </Summary> /// <Param name = "message"> Message Text to be displayed </param>/ // <Param name = "close"> close the current page </param> Public static void httpcontextalert (string message, bool close) {If (close) {httpcontext. current. response. write ("<script language = 'javascript 'Type = 'text/JavaScript '> alert ('" + message + "'); window. close () </SCRIPT> "); httpcontext. current. response. end ();} else {httpcontext. current. response. write ("<script language = 'javascript 'Type = 'text/JavaScript '> alert ('" + message + "') </SCRIPT>"); httpcontext. current. response. write ("<SCRIPT> history. go (-1) </SCRIPT> "); httpcontext. current. response. end () ;}# endregion # region uses page. registerclientscriptblock dialog box /// <summary> // webpage message dialog box /// </Summary> /// <Param name = "page"> dialog box </Param> /// <Param name = "message"> Message Text to be displayed </param> Public static void pagealert (system. web. UI. page, string message) {message = message. replace ("\\","\\\\"). replace ('\ n '. tostring (), "\ n "). replace ('\ R '. tostring (), "\ r "). replace ("'","\\'"). replace ("\" "," \ ""); // remove the special character page that may cause a script error. registerclientscriptblock ("_ alertmessage", "<script language = 'javascript '> alert ('" + message + "'); </SCRIPT> ");} /// <summary> /// webpage message dialog box /// </Summary> /// <Param name = "page"> dialog box </param> // /<Param name = "message"> Message Text to be displayed </param> // <Param name = "src"> Click OK to go to the public page </param> static void pagealert (system. web. UI. page, string message, string SRC) {message = message. replace ("\\","\\\\"). replace ('\ n '. tostring (), "\ n "). replace ('\ R '. tostring (), "\ r "). replace ("'","\\'"). replace ("\" "," \ ""); // remove the special character page that may cause a script error. registerclientscriptblock ("_ alertmessage", "<script language = 'javascript '> alert ('" + message + "'); location. href = '"+ SRC +"' </SCRIPT> ");} /// <summary> /// webpage message dialog box /// </Summary> /// <Param name = "page"> dialog box </param> // /<Param name = "message"> Message Text to be displayed </param> // <Param name = "close"> close the current page </param> Public static void pagealert (system. web. UI. page, string message, bool close) {message = message. replace ("\\","\\\\"). replace ('\ n '. tostring (), "\ n "). replace ('\ R '. tostring (), "\ r "). replace ("'","\\'"). replace ("\" "," \ ""); // remove special characters that may cause script errors if (close) {page. registerclientscriptblock ("_ alertmessage", "<script language = 'javascript '> alert ('" + message + "'); window. close () </SCRIPT> ");} else {page. registerclientscriptblock ("_ alertmessage", "<script language = 'javascript '> alert ('" + message + "'); </SCRIPT> ");}} # endregion # Use scriptmanager for region. registerclientscriptblock dialog box /// <summary> // webpage message dialog box /// </Summary> /// <Param name = "control"> Control of the dialog box </Param >/// <Param name = "message"> Message Text to be displayed </param> Public static void scriptmanageralert (system. web. UI. control, string message) {message = message. replace ("\\","\\\\"). replace ('\ n '. tostring (), "\ n "). replace ('\ R '. tostring (), "\ r "). replace ("'","\\'"). replace ("\" "," \ ""); // remove the special characters scriptmanager that may cause a script error. registerclientscriptblock (control, control. getType (), "_ alertmessagewithcontrol", "alert ('" + message + "')", true );} /// <summary> /// webpage message dialog box /// </Summary> /// <Param name = "control"> Control </param> // /<Param name = "message"> Message Text to be displayed </param> // <Param name = "src"> Click OK to go to the public page </param> static void scriptmanageralert (system. web. UI. control, string message, string SRC) {message = message. replace ("\\","\\\\"). replace ('\ n '. tostring (), "\ n "). replace ('\ R '. tostring (), "\ r "). replace ("'","\\'"). replace ("\" "," \ ""); // remove the special characters scriptmanager that may cause a script error. registerclientscriptblock (control, control. getType (), "_ alertmessagewithcontrol", "alert ('" + message + "'); location. href = '"+ SRC +"' ", true );} /// <summary> /// webpage message dialog box /// </Summary> /// <Param name = "control"> Control </param> // /<Param name = "message"> Message Text to be displayed </param> // <Param name = "close"> close the current page </param> Public static void scriptmanageralert (system. web. UI. control, string message, bool close) {message = message. replace ("\\","\\\\"). replace ('\ n '. tostring (), "\ n "). replace ('\ R '. tostring (), "\ r "). replace ("'","\\'"). replace ("\" "," \ ""); // remove special characters that may cause script errors if (close) {scriptmanager. registerclientscriptblock (control, control. getType (), "_ alertmessagewithcontrol", "alert ('" + message + "'); window. close () ", true);} else {scriptmanager. registerclientscriptblock (control, control. getType (), "_ alertmessagewithcontrol", "alert ('" + message + "')", true) ;}# endregion }}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.