Step 1: Open visual studio -> website
-> Asp.net Empty website then choose any name and click OK
Step 2: From solution explorer right click on your website name and
then choose add new item -> web form give name to that web form and click OK
Step 3: Take 6 label,5 Text box , 1 button and RegularExpressionvalidator.
Design will look like:
RegularExpressionvalidator is used so that if user enter email id in incorrect
format it will show an error.
Way to set RegularExpressionvalidator is Properties of RegularExpressionvalidator->
validation expression -> Internet email address
Code used at default.aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lem" runat="server" Text="Email id"></asp:Label>
<asp:TextBox ID="tem" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="tem"
ErrorMessage="Email id should be in format [email protected]" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
<br />
<br />
<asp:Label ID="lpwd" runat="server" Text="Password"></asp:Label>
<asp:TextBox ID="tpwd" runat="server" TextMode="Password"></asp:TextBox>
<br />
<br />
<asp:Label ID="lre" runat="server" Text="Receiver Email ID"></asp:Label>
<asp:TextBox ID="tre" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="tre"
EnableViewState="False" ErrorMessage="Email id should be in format aba@anyserver(gmail/yahoo/hotmail).com"
SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>




pankaj pandeyPosted Oct 25, 2013, 4:05 AM
g8 Thanks
ankur saxenaPosted Oct 14, 2013, 12:06 PM
thanks priyanka.....