programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Wednesday, October 15, 2014 Email Address Validation Using Regular Expression

Email Address Validation for ASP.NET ( Validation Using Regular Expression):

In this post we learn how to use regular Expression in C#code for validation of Email id in web application. Some time we see many web sites use the Email validation in registration time, subscribe time etc. So how we can use Email validation in my web site.

Basically the JavaScript use for the validation in client site. But also provide a validation class we can use this for check the valid information of not. Email Address Validation Using Regular Expression(parijat)

Asp:RegularExpressionValidator for Email address:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EmailValidation_Csharp.aspx.cs"
    Inherits="EmailValidation_Csharp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
    <title> Regular Expression to validate Email Address</title>
    <style type="text/css">
            color: #990000;
            font-weight: bold;
            color: #990000;
            text-decoration: underline;
            font-family: Arial, Helvetica, sans-serif;
    <form id="form1" runat="server">
    <div align="center">
    <h2 class="style2">Check valid Email-ID by C# code</h2>
    <table style="width: 396px; height: 128px; background-color: #00CCFF">
                <span class="style1">Enter Email:</span>
            <td align="left">
                <asp:TextBox ID="txtEmail" runat="server" Width="195px" />
            <td align="left" valign="top">
                <asp:Button ID="btncheck" runat="server" Text="Validate Email"
                    style="color: #990000; font-weight: 700" onclick="btncheck_Click" />
                <br />
                <br />
    <asp:Label ID="lblmsg" runat="server" Style="font-weight: bold;" />
    <br />
    This Example in <a href=""> Tutorial
        <br />

Validate an email address using c#:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;

public partial class EmailValidation_Csharp : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)


    protected void btncheck_Click(object sender, EventArgs e)

        bool isEmail = Regex.IsMatch(txtEmail.Text.Trim(), @"\A(?:[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)\Z");
        if (!isEmail)
            lblmsg.Text = "Enter Valid Email ID..";
            lblmsg.ForeColor = System.Drawing.Color.Red;
            lblmsg.Text = "Valid Email";
            lblmsg.ForeColor = System.Drawing.Color.Green;

Other ASP.NET Programming Post:  
·                     Using jQuery change Background color of DIV
·                     JQuery Change Div Background Color Randomly
·                     Get selected radio button values using JQuery.
·                     How do you do html text encodes using JavaScript
·                     Limit Number of Characters in a TextArea using jQuery
·                     Characters inTextbox  in asp.netusing jquery:
·                     Drag and Drop Sortable Lists using jQueryUI
·                     jquery tooltip with css in web page
·                     Ajax ColorPickerExtender in ASP.NET Example
·                     What is the Ajax colorpicker,How to use Ajax colorpicker
·                     JQuery UI Datepicker (Calendar) with textbox
·                     Adding or binding tooltip in each item of dropdownlist
·                     jquery disable or Enable submit button after validation
·                     Example of Adding ToolTip for each Dropdown List Item in C#
·                     Displaying the textbox value in javascript Messagebox
·                     Enable Disable Submit Button using jQuery
·                     jquery disable or Enable submit button after validation
·                     What is ASP.NET FRAMEWORK PART 1 Programming
·                     Display selected Date from data base into calendar
·                     How to create Line chart:,How to Make Data Table By C# code:
·                     Example of Crystal report(Crystal_report_in programming )
·                     SQL Helper ClassExample of how to add captcha in using C#
·                     Sql Query for Programming How to create graph in
·                     How to use CAPTCHA in,How to use regular expression
·                     Show tooltip dropdownlist items by mouseoverevent using C# example  

No comments:

Post a Comment