Common functions collection page 2/2
Updated: June 16, 2020 22:27:47 Submission: mdxy-dxy
This article introduces you to the collection of commonly used functions, mainly including getting the site user IP, removing the last ',' number of the string, removing the first '/' number of the string, etc. Interested friends follow the editor to take a look.
//The dialog box pops up public static void salest(string str) { ("<script>alert('" + str + "');</script>"); } /// <summary> /// Show the message prompt box and return to the previous page /// </summary> /// <param name="page">The current page pointer, generally this</param> /// <param name="strMsg">Prompt message</param> public static void ShowGoHistory( page, string strMsg) { ((), "message", "<script language='javascript' defer>alert('" + () + "');(-1);</script>"); } /// <summary> /// Show the message prompt dialog box and perform the page jump /// </summary> /// <param name="page">The current page pointer is generally this</param> /// <param name="strMsg"> Prompt message</param> /// <param name="url"> The target URL for jump</param> public static void ShowRedirect( page, string strMsg, string url) { StringBuilder Builder = new StringBuilder(); ("<script language='javascript' defer>"); ("alert('{0}');", strMsg); ("='{0}'", url); ("</script>"); ((), "message", ()); } //In order to insert single quotes public static string delSingle(string str) { return ("'", "''"); } //Exported as Excel public static void ToExcel(ctl) { ("Content-Disposition", "attachment;filename="); = "UTF-8"; = ; = "application/ms-excel";//image/JPEG;text/HTML;image/GIF;-excel/msword = false; tw = new (); hw = new (tw); (hw); (()); (); } ///using ; ///using ; /// <summary> /// MD5 function /// </summary> /// <param name="str">Raw string</param> /// <returns>MD5 result</returns> public static string MD5(string str) { byte[] b = (str); b = new MD5CryptoServiceProvider().ComputeHash(b); string ret = ""; for (int i = 0; i < ; i++) ret += b[i].ToString("x").PadLeft(2, '0'); return ret; } ///using ; ///using ; /// <summary> /// Get source file content based on Url /// </summary> /// <param name="url">Legal Url address</param> /// <returns></returns> public static string GetSourceTextByUrl(string url) { WebRequest request = (url); = 20000;//20 seconds timeout WebResponse response = (); Stream resStream = (); StreamReader sr = new StreamReader(resStream); return (); }
Summarize
This is all about this article about favorites of commonly used functions. For more relevant commonly used functions, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!
Previous page12Read the full text