Regular Expression for Email Address validation in C#

The task at hand is to validate the Textbox in asp.net for a valid email address.

We can attach a RegularExpressionValidator to the text box with the following regular expression:

<asp:RegularExpressionValidator ValidationExpression="^([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})(\]?)$" ID="rxpEmail" runat="server"
ErrorMessage="Email Address is not valid" Text="*" Display="Static" ControlToValidate="txtEmail"></asp:RegularExpressionValidator>

UPDATES
Well i searched the net for the standards of a valid email id and i came across with a wonderful article at

I Knew How To Validate An Email Address Until I Read The RFC

It gives a an idea of what an exact RFC standard for the email id is.

I believe that we should follow validations which are quite obvious to the users and allow only standard email addresses.

kick it on DotNetKicks.com

Shout it

pimp it

Help file from XML Documentation using NDoc

In this article we will explore the usage of Open Source tool NDoc to create
MSDN type help file from the xml documentation in a DotNet assembly.

To know how we can create XML documentation visit the link
XML Documentation in Visual Studio using GhostDoc

Ndoc basically uses two sources to generate documentation.
One is assembly file and second is pre generated XML documentation file which we can generate Visual studio in the following way:
Go to the options in Visual studio and there we have an option to specify the path where the studio will place the file.

Now Ndoc simple exe which takes the path of Assembly and the Xml document file as generated in prevoius step and it automatically creates a CHM or web bases help file.

kick it on DotNetKicks.com

Shout it

pimp it

XML Documentation in Visual Studio using GhostDoc

In this article we will explore how to generate the xml documentation in Visual Studio for our .NET code.

Basically Every .NET assembly can contain the comments as documentation which we place after ‘///'(Triple slash) in our code.

For example:
If we write the following code in visual studio it gets assigned into assembly as xml documentation:

    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        ///XML Comment
        ///Can be used to generate a document 
        ///using tools like NDoc
     }
     

Now there exists a wonderful tool GhostDoc which can automate this documentation for you. It basically extracts the documentation from the documentation of the original classes embeds it into the code.

The documentation for the page load method in the above example changed with the help of GhostDoc like this:

/// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    /// *************************************************************
    /// Created By: Ankit Goyal
    /// Date: 5/22/2009
    /// Time: 12:06 PM
    /// *************************************************************
    protected void Page_Load(object sender, EventArgs e)
    {   
    }
    

The quality of documentation which GhostDoc generates also depends on the names of classes method and variables you create. Conventions if followed along with GhostDoc produces superb documentation at ease.

Now once the xml documention has been embedded into the code it can be used to create msdn type help file for the code. To know about it please visit:
Help file from XML Documentation using NDoc

References:
Ghostdoc Home Page

kick it on DotNetKicks.com

Shout it

pimp it