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