Common classes in projects

Source: Internet
Author: User

1. Paging Data Model: PagedDataModel.cs

Useful: Encapsulates the paging data into a class

 Public classPageddatamodel<t>{    /// <summary>    ///Total Pages/// </summary>     Public intPageCount; /// <summary>    ///total number of rows/// </summary>     Public intRowCount; /// <summary>    ///Current page number/// </summary>     Public intPageIndex; /// <summary>    ///Current page Number data/// </summary>     PublicIlist<t>pagedlist;}

2. Data Helper class: DataHelper.cs

Useful: Data is processed and returned in a certain format

 Public Static classdatahelper{/// <summary>    ///JS Serializer/// </summary>    StaticJavaScriptSerializer jss=NewJavaScriptSerializer (); /// <summary>    ///convert an object to a JSON array format string/// </summary>    /// <param name= "obj" ></param>    /// <returns></returns>     Public Static stringObjtojson (Objectobj) {        returnJSS.    Serialize (obj); }    /// <summary>    ///returns the MD5 encrypted string/// </summary>    /// <param name= "str" ></param>    /// <returns></returns>     Public Static stringMD5 (stringstr) {        returnSystem.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile (str,    FormsAuthPasswordFormat.MD5.ToString ()); }}

3. Page Help class: PageHelper.cs

Useful: When displaying JS information on the forward platform

 Public classpagehelper{/// <summary>    ///reads a file of the specified path and returns a string format/// </summary>    /// <param name= "strpath" >file path-Physical path</param>    /// <returns></returns>     Public Static stringReadFile (stringstrpath) {        returnFile.readalltext (strpath); }    /// <summary>    ///get hints and jump JS code strings/// </summary>    /// <param name= "STRMSG" ></param>    /// <param name= "Strbackurl" ></param>     Public Static voidWritejsmsg (stringSTRMSG,stringStrbackurl) {        stringStrback ="<script>alert ("+ STRMSG +"); window.location= '"+ Strbackurl +"';</script>";    HttpContext.Current.Response.Write (Strback); }    /// <summary>    ///Jump JS Code string/// </summary>    /// <param name= "STRMSG" ></param>     Public Static voidWritejsmsg (stringSTRMSG) {        stringStrback ="<script>alert ("+ STRMSG +");</script>";    HttpContext.Current.Response.Write (Strback); }}

4. Validation Help class: ValidateHelper.cs

Useful: Validating data

 Public classvalidatehelper{StaticRegex regisnum=NewRegex ("^[0-9]+$"); /// <summary>    ///Verify that the parameter is an integral type value/// </summary>    /// <param name= "Strnum" ></param>    /// <returns></returns>     Public Static BOOLIsnum (stringstrnum) {        returnRegisnum.ismatch (Strnum); }}

5. Asynchronous Message Processing class AjaxMsgHelper.cs

Usefulness: Returns information to be returned in a certain content form.

 Public Static classajaxmsghelper{/// <summary>    ///return a message in JSON format/// </summary>    /// <param name= "Statu" >Status Code</param>    /// <param name= "MSG" >status information</param>    /// <param name= "Data" >Return Data</param>    /// <param name= "Nexturl" >Jump URL</param>     Public Static voidAjaxmsg (stringStatu,stringMsgstringDatastringNexturl) {        //{"Statu": "Err", "MSG": "Error", "Data": [{},{}], "Nexturl": "Login.aspx"}        stringSTRMSG ="{\ "statu\": \ ""+statu+"\ ", \" msg\ ": \""+msg+"\ ", \" data\ ":"+ (data==NULL?"NULL":d ATA) +", \ "nexturl\": \ ""+nexturl+"\"}";    HttpContext.Current.Response.Write (STRMSG); }     Public Static voidAjaxmsg (stringStatu,stringMsgstringdata) {ajaxmsg (Statu,msg,data,"NULL"); }     Public Static voidAjaxmsg (stringStatu,stringmsg) {ajaxmsg (statu,msg,NULL,NULL); }}

Common classes in projects

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.