Source. Library. Web. js. Alert
Last Update:2018-12-05
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 }}