Commonhelper public class

Source: Internet
Author: User

public static class Commonhelper Common helper class

usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text.RegularExpressions;usingsystem.web;namespaceaspnetashx{ Public Static classCommonhelper {#region1.0 reading a file's content string based on a relative path +string getfilecontent (string filePath)/// <summary>        ///reads a file's content string based on a relative path/// </summary>        /// <param name= "FilePath" >relative path of the file</param>        /// <returns></returns>         Public Static stringGetfilecontent (stringFilePath) {            //get absolute path (physical path) based on relative path (virtual path)            stringPhypath =HttpContext.Current.Server.MapPath (FilePath); //Read File contents            stringStrcontent =System.IO.File.ReadAllText (Phypath); //Return file Contents            returnstrcontent; }         #endregion        #region2.0 Direct Output JS message and complete jump +writejs (string msg, string URL)/// <summary>        ///Direct Output JS message/// </summary>        /// <param name= "msg" ></param>         Public Static voidWritejs (stringmsg) {HttpContext.Current.Response.Write ("<script>alert ('"+ msg +"');</script>"); }        /// <summary>        ///output JS message directly and complete the jump/// </summary>        /// <param name= "msg" ></param>        /// <param name= "url" ></param>         Public Static voidWritejs (stringMsgstringURL) {HttpContext.Current.Response.Write ("<script>alert ('"+ msg +"'); window.location= '"+ URL +"';</script>"); }         #endregion        #region3.0 using regular expressions to verify that a parameter is a numeric +bool isnum (string strnumber)/// <summary>        ///use regular expressions to verify that a parameter is a numeric value/// </summary>        /// <param name= "Strnumber" ></param>        /// <returns></returns>         Public Static BOOLIsnum (stringStrnumber) {Regex reg=NewRegex (@"^\d+$");//Numeric Regular expression (one or more numbers)            returnReg.        IsMatch (Strnumber); }         #endregion    }}

Commonhelper public class

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.