RSS

Tag Archives: asp.net

Regular Expressions Patterns


RegExp

  • Integer (positive and negative)
    • ^[+-]?\d+$
    • ^[+-]?[0-9]+$
    • Matches: any signed integer
  • Integer (positive)
    • ^[0-9]+$
    • Matches: any positive signed integer
  • Integer (negative)
    • ^[-][0-9]+$
    • Matches: any negative signed integer
  • Decimal (positive and negative)
    • ^[-+]?\d+(\.\d+)?$
    • ^[+-]?[0-9]*(?:\.[0-9]*)?$
    • Matches: 123 | -123.45 | +123.56
  • Decimal (positive)
    • ^[+]?[0-9]*(?:\.[0-9]*)?$
    • Matches: 123 | 123.45 | +123.56
  • Decimal (negative)
    • ^[-][0-9]*(?:\.[0-9]*)?$
    • Matches: -123 | -123.45 | -123.56
  • Number (positive and negative)
    • ^[+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?$
    • Matches: 23 | -17.e23 | +.23e+2  
  • Natural Number
    • ^[0-9]*[1-9]+$|^[1-9]+[0-9]*$
  • Alphabetical
    • [^a-zA-Z]
    • Matches: ABC | Test | xyz
  • Alphanumeric
    • [^a-zA-Z0-9]
    • ^[a-zA-Z0-9_]*$
    • Matches: ABC | Test123
  • E-Mail
    • ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$
    • Matches: AhmedNegm@WindowsLive.com
  • Date
    • ^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))|^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d+$
    • Matches: this expression validates a date field in dd/mm/yyyy  and mm/dd/yyyy format
  • Temperature
    • ^[-+]?\d*(\.\d+)?( )?(Celsius|C|c|CELSIUS|Fahrenheit|F|f|FAHRENHEIT|Kelvin|K|k|KELVIN)?$
    • Matches: 34F | 56 Celsius | 22C
  • Egyptian National ID
    • (2|3)[0-9][1-9][0-1][1-9][0-3][1-9](01|02|03|04|11|12|13|14|15|16|17|18|19|21|22|23|24|25|26|27|28|29|31|32|33|34|35|88)\d\d\d\d\d
  • Egyptian Mobile Number
    • (201)[0-9]{9}
  • Hexadecimal String
    • ^[0-9A-Fa-f]+$
    • Matches: 062706440644064700200623064306280631
 
 

Tags: , , , , , , , , , , , , , , , , , , ,

Razor View Engine in ASP .NET MVC 3


Simple overview

The Razor View Engine is new to ASP.NET MVC 3 and is the default view engine moving forward. This post focuses on Razor and does not cover the Web Forms View Engine. Razor is the response to one of the most requested suggestions received by the ASP.NET MVC feature team — to provide a clean, lightweight simple view engine that didn’t contain the “syntactic cruft” contained in the existing Web Forms View Engine. Many developers felt that all that syntactic noise required to write a view created friction when trying to read that view. This request was finally answered in version 3 of ASP.NET MVC with the introduction of the new Razor View Engine.

Read the rest of this entry »

 
Leave a comment

Posted by on January 16, 2012 in ASP .NET

 

Tags: , , , , , , , , , ,

What is the SOAP ??


SOAP is a protocol specification to invoke methods on servers, services, components and objects. The available procedure of using XML and HTTP as a method invocation mechanism is implied by SOAP. A small number of HTTP headers that facilitate firewall/proxy filtering are authorized by the SOAP specification. The SOAP specification also mandates an XML vocabulary that is used to represent method parameters, return values, and exceptions.

To exchange structured and typed information between peers in a decentralized, distributed environment using XML, SOAP presents an uncomplicated mechanism. SOAP defines a simple mechanism for expressing application semantics by providing a modular packaging model and encoding mechanisms for encoding data within modules instead of defining any application semantics such as a programming model or implementation specific semantics. This allows SOAP to be used in a large variety of systems ranging from messaging systems to RPC.

Read the rest of this entry »

 
Leave a comment

Posted by on January 5, 2012 in ASP .NET

 

Tags: , , , , , , , , , ,

Changing ASPX’s MasterPage at Run-time


In this post we will learn how to change the MasterPage for any page.aspx … Really, sometimes we have to change the MasterPage at the run-time of the application.

First you have to know that the event we will write the code under it is “Page_PreInit” … as following:

protected void Page_PreInit(object sender, EventArgs e)
{
//check the user weather user is logged in or not
if (Session[“LoggedIn”] == null)
this.Page.MasterPageFile = “~/User.master”;
}
else
{
this.Page.MasterPageFile = “~/Admin.master”;
}

 
Leave a comment

Posted by on January 2, 2012 in ASP .NET

 

Tags: , , , , , ,

Server.Transfer() vs. Reponse.Redirect() in ASP .NET


Server.Transfer()

  • Server.Transfer() is used to navigate between the pages of the same site only.
  • Server.Transfer() transfers the information by itself from a page to another.
  • It uses QueryString internally to transfer the information from a page to another within the same site.
  • When you try to use this method (Server.Transfer(“MyWebForm.aspx”)) executed, and you are in another page called “TestPage.aspx” notice this “While navigation to any page the URL in address bar of your browser will not changed”.

Response.Redirect()

  • Response.Redirect() is used to navigate between the pages of the same site and more than on site (any URL).
  • Response.Redirect() not transfers the information by itself from a page to another.
  • It uses QueryString externally to transfer the information from a page to another.
  • When you try to use this method (Response.Redirect(“MyWebForm.aspx”)) executed, and you are in another page called “TestPage.aspx” notice this “While navigation to any page the URL in address bar of your browser will changed”.
 
Leave a comment

Posted by on December 26, 2011 in ASP .NET

 

Tags: , , , ,

Page Life Cycle vs. Event Life Cycle in ASP .NET


Page Life cycle

  1. Page Request
  2. Start
  3. Initialization
  4. Load
  5. Post back Event handling
  6. Rendering
  7. Unload

Event life cycle

  1. Preinit
  2. Init
  3. InitComplete
  4. Preload
  5. Load
  6. LoadComplete
  7. Prerender
  8. PreRenderComplete
  9. SaveStateComplete
  10. Render
  11. Unload

 

Useful linkASP .NET Events Life Cycles

 
Leave a comment

Posted by on December 26, 2011 in ASP .NET

 

Tags: , , , , , , ,