QueryString Address bar parameters

Source: Internet
Author: User

Using System.Web;
Using System.Text.RegularExpressions;

namespace Dotnet.utilities
{
// <summary>
/// QueryString Address bar parameters
// </summary>
Public class QueryString
{
#region equals request.querystring, if NULL returns NULL "", returns Request.querystring[name]
// <summary>
/// equals request.querystring; returns null "" If NULL, otherwise returns REQUEST.QUERYSTRING[NAME]
// </summary>
// <param name= "name" ></param>
// <returns></returns>
Public static string Q (string name)
{
return Request.querystring[name] = = null? "": Request.querystring[name];
}
#endregion


//<summary>
//equals Request.Form returns NULL if NULL "", return Request.form[name]
//</summary>
//<param name= "name" ></PARAM>
///<returns></returns>
public static string F (string name)

return request.form[name] = = Null? "": Request.form[name]. ToString ();


#region gets the ID in the URL
//<summary
///get the ID in the URL
//</ Summary>
///<param name= "name" ></PARAM>
///<returns></returns>
public static int QId (string name)

return Strtoid (Q (name));

#endregion


#region gets the correct ID, if not a positive integer, returns 0
// <summary>
///get the correct ID, if not a positive integer, return 0
//</summary>
///<param name= "_value" ></PARAM>
///<returns> returns the correct integer ID, failed to return 0</RETURNS>
public static int strtoid (string _value)

if (Isnumberid (_value))
return int. Parse (_value);
else
return 0;

#endregion


#region checks whether a string is a purely numeric character and is typically used for validation of query string parameters.
<summary>
Checks whether a string is a purely numeric component, and is typically used to validate validation of query string parameters.
</summary>
<param name= "_value" > String to be validated: </param>
<returns> is a valid bool value. </returns>
public static bool Isnumberid (string _value)
{
Return Quickvalidate ("^[1-9]*[0-9]*$", _value);
}
#endregion


#region quickly verifies that a string conforms to the specified regular expression.
// <summary>
/// fast verifies whether a string conforms to the specified regular expression.
// </summary>
/// <param name= "_express" > Regular expression content. </param>
/// <param name= "_value" > string to be validated. </param>
// <returns> is a valid bool value. </returns>
Public static bool Quickvalidate (string _express, string _value)
{
if (_value = = null) return false;
regex myregex = new Regex (_express);
if (_value. Length = = 0)
{
return false;
}
return Myregex.ismatch (_value);
}
#endregion


#region class Internal invocation
// <summary>
// HttpContext Current
// </summary>
Public static HttpContext Current
{
get {return httpcontext.current;}
}
// <summary>
/// HttpContext current HttpRequest Request get {return current.request;
// </summary>
Public static HttpRequest Request
{
get {return current.request;}
}
// <summary>
/// HttpContext current HttpRequest Request get {return current.request; HttpResponse Response return current.response;
// </summary>
Public static HttpResponse Response
{
get {return current.response;}
}
#endregion
}
}

QueryString Address bar parameters

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.