Search This Blog

Sunday, August 29, 2010

Registration Page.aspx

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

< !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 runat="server">
< title> Untitled Page< /title>
< script language="javascript" type="text/javascript">
function SetFocusOnPhone(PreviousControl, NextControl)
{
if(document.getElementById(PreviousControl).value.length > =3)
{
document.getElementById(NextControl).focus();
}
}


function Validate(sender,args)
{
var txt1 = document.getElementById("txtPhone1");
var txt2 = document.getElementById("txtPhone2");
var txt3 = document.getElementById("txtPhone3");

if((txt1.value == "") || (txt2.value == "") || (txt3.value == ""))
{
return args.IsValid = false;
}
else{
return args.IsValid = true;
}

}

function Validateddl(sender, args)
{
var str = new String();
str = args.Value;

if (str == "0") {
args.IsValid = false;

}
else {
args.IsValid = true;
}
}
< /script>
< /head>
< body>
< form id="form1" runat="server">

< asp:ScriptManager ID="sptMgrLogin" runat="server" EnablePageMethods="true">
< /asp:ScriptManager>

< table>
< tr>
< td>
 
< /td>
< /tr>
< tr>
< td>
< span class=""> * First Name < /span>
< /td>
< td>
< asp:TextBox ID="txtFirstName" runat="server" MaxLength="25" TabIndex ="1"> < /asp:TextBox>
< asp:RequiredFieldValidator ID="reqFirstName" runat="server" ControlToValidate="txtFirstName"
Display="None" EnableClientScript="true" ErrorMessage="Please enter first name"
ForeColor="#00f6ff" SetFocusOnError="true">
< /asp:RequiredFieldValidator>
< cc1:ValidatorCalloutExtender ID="validfirstname" runat="server" HighlightCssClass="validatorCalloutHighlight"
TargetControlID="reqFirstName">
< /cc1:ValidatorCalloutExtender>
< /td>
< /tr>
< tr>
< td>
< span class=""> * Last name < /span>
< /td>
< td>
< asp:TextBox ID="txtLastName" runat="server" MaxLength="25" TabIndex="2"> < /asp:TextBox>
< asp:RequiredFieldValidator ID="reqlastname" runat="server"
ControlToValidate="txtLastName" Display="None" EnableClientScript="true"
ErrorMessage="Please enter last name" ForeColor="#00f6ff"
SetFocusOnError="true">
< /asp:RequiredFieldValidator>
< cc1:ValidatorCalloutExtender ID="validextendlastname" runat="server"
HighlightCssClass="validatorCalloutHighlight" TargetControlID="reqlastname">
< /cc1:ValidatorCalloutExtender>
< /td>
< /tr>
< tr>
< td>
< span class=""> * School < /span>
< /td>
< td>
< asp:DropDownList ID="ddlSchool" runat="server" Width="90px" TabIndex="3" AutoPostBack="True">
< asp:ListItem Value="0" Text="Select"> < /asp:ListItem>
< asp:ListItem Value="1"> St.Francis< /asp:ListItem>
< asp:ListItem Value="2"> Pauls< /asp:ListItem>
< asp:ListItem Value="3"> St.Joseph< /asp:ListItem>
< /asp:DropDownList>
< asp:RequiredFieldValidator ID="reqSchool" runat="server"
ControlToValidate="ddlSchool" Display="None" EnableClientScript="true"

SetFocusOnError="true">
< /asp:RequiredFieldValidator>
< asp:CustomValidator ID="cvddlSchoolName" ControlToValidate="ddlSchool" ClientValidationFunction="Validateddl"
Display="None" OnServerValidate="ValidateDropdown" runat="server" ErrorMessage="Please select school name"
SetFocusOnError="true"> < /asp:CustomValidator>

< cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender8" runat="server"
HighlightCssClass="validatorCalloutHighlight" TargetControlID="cvddlSchoolName">
< /cc1:ValidatorCalloutExtender>

< /td>
< /tr>
< tr>
< td>
< span class=""> * User Name < /span>
< /td>
< td>
< asp:TextBox ID="txtUserName" runat="server" MaxLength="15" TabIndex="4"> < /asp:TextBox>
< asp:RequiredFieldValidator ID="reqUser" runat="server"
ControlToValidate="txtUserName" Display="None" EnableClientScript="true"
ErrorMessage="Please enter user name"
SetFocusOnError="true">
< /asp:RequiredFieldValidator>
< cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender6" runat="server"
HighlightCssClass="validatorCalloutHighlight" TargetControlID="reqUser">
< /cc1:ValidatorCalloutExtender>
< /td>
< /tr>
< tr>
< td>
< span class=""> < /span> * Password
< /td>
< td>
< asp:TextBox ID="txtPassword" runat="server" TextMode="Password" MaxLength="15" TabIndex="5"> < /asp:TextBox>
< asp:RequiredFieldValidator ID="reqPassword" runat="server"
ControlToValidate="txtPassword" EnableClientScript="true"
ErrorMessage="Please enter password" SetFocusOnError="true" Display="None">
< /asp:RequiredFieldValidator>
< cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server"
HighlightCssClass="validatorCalloutHighlight" TargetControlID="reqPassword">
< /cc1:ValidatorCalloutExtender>
< /td>
< /tr>
< tr>
< td>
< span class=""> < /span> * E-mail
< /td>
< td>
< asp:TextBox ID="txtEmail" runat="server" MaxLength="50" TabIndex="6"> < /asp:TextBox>
< asp:RequiredFieldValidator ID="reqEmail" runat="server"
ControlToValidate="txtEmail" Display="None" EnableClientScript="true"
ErrorMessage="Please enter e-mail" ForeColor="#00f6ff" SetFocusOnError="true">
< /asp:RequiredFieldValidator>
< asp:RegularExpressionValidator ID="regEmail" runat="server"
ControlToValidate="txtEmail" Display="None" EnableClientScript="true"
ErrorMessage="Please enter valid e-mail" ForeColor="#00f6ff"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"> < /asp:RegularExpressionValidator>
< cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender3" runat="server"
HighlightCssClass="validatorCalloutHighlight" TargetControlID="reqEmail">
< /cc1:ValidatorCalloutExtender>
< cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender7" runat="server"
HighlightCssClass="validatorCalloutHighlight" TargetControlID="regEmail">
< /cc1:ValidatorCalloutExtender>
< /td>
< /tr>
< tr>
< td>
< span class=""> < /span> * Phone Number
< /td>
< td >
(< asp:TextBox ID="txtPhone1" runat="server" MaxLength="3" Width="30PX"
onkeyup="SetFocusOnPhone('txtPhone1','txtPhone2')" TabIndex="7">
< /asp:TextBox> )
< span style="padding-left: 5px;"> -< /span>
< asp:TextBox ID="txtPhone2" runat="server" MaxLength="3"
onkeyup="SetFocusOnPhone('txtPhone2','txtPhone3')" Width="30PX" TabIndex="8" > < /asp:TextBox>
< span style="padding-left: 5px;"> -< /span>
< asp:TextBox ID="txtPhone3" runat="server" MaxLength="4"
Width="30PX" TabIndex="9" > < /asp:TextBox>
< asp:RequiredFieldValidator ID="reqtxtPhon1" runat="server"
ControlToValidate="txtPhone1" Display="None" EnableClientScript="true"
ErrorMessage="Please enter phone number" SetFocusOnError="true">
< /asp:RequiredFieldValidator>
< asp:RegularExpressionValidator ID="regularExpPhone1" runat="server"
ControlToValidate="txtPhone1" Display="None" EnableClientScript="true"
ErrorMessage="Please enter valid phone format (###)" SetFocusOnError="true"
ValidationExpression="\d{3}"> < /asp:RegularExpressionValidator>
< cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender12" runat="server"
FilterType="Numbers" TargetControlID="txtPhone1">
< /cc1:FilteredTextBoxExtender>
< cc1:ValidatorCalloutExtender ID="validReqularExprePh" runat="server"
HighlightCssClass="validatorCalloutHighlight"
TargetControlID="regularExpPhone1">
< /cc1:ValidatorCalloutExtender>
< asp:RequiredFieldValidator ID="ReqPhone2" runat="server"
ControlToValidate="txtPhone2" Display="None" EnableClientScript="true"
ErrorMessage="Please enter phone number" ForeColor="#00f6ff"
SetFocusOnError="true"> < /asp:RequiredFieldValidator>
< asp:RegularExpressionValidator ID="reqgularExpPhon2" runat="server"
ControlToValidate="txtPhone2" Display="None" EnableClientScript="true"
ErrorMessage="Please enter valid phone format (###)" ForeColor="#00f6ff"
SetFocusOnError="true" ValidationExpression="\d{3}"> < /asp:RegularExpressionValidator>
< cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender14" runat="server"
FilterType="Numbers" TargetControlID="txtPhone2">
< /cc1:FilteredTextBoxExtender>
< cc1:ValidatorCalloutExtender ID="validExReguPhone2" runat="server"
HighlightCssClass="validatorCalloutHighlight"
TargetControlID="reqgularExpPhon2">
< /cc1:ValidatorCalloutExtender>
< asp:RequiredFieldValidator ID="reqPhone3" runat="server"
ControlToValidate="txtPhone3" Display="None" EnableClientScript="true"
ErrorMessage="Please enter phone number" ForeColor="#00f6ff"
SetFocusOnError="true"> < /asp:RequiredFieldValidator>
< cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender4" runat="server"
HighlightCssClass="validatorCalloutHighlight" TargetControlID="reqPhone3">
< /cc1:ValidatorCalloutExtender>
< asp:RegularExpressionValidator ID="regularExpPhon3" runat="server"
ControlToValidate="txtPhone3" Display="None" EnableClientScript="true"
ErrorMessage="Please enter valid phone format (####)" SetFocusOnError="true"
ValidationExpression="\d{4}"> < /asp:RegularExpressionValidator>
< cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender13" runat="server"
FilterType="Numbers" TargetControlID="txtPhone3">
< /cc1:FilteredTextBoxExtender>
< cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender5" runat="server"
HighlightCssClass="validatorCalloutHighlight" TargetControlID="regularExpPhon3">
< /cc1:ValidatorCalloutExtender>
< asp:CustomValidator ID="cvPhone" runat="server"
ClientValidationFunction="Validate" ControlToValidate="txtPhone3"
Display="None" EnableClientScript="true"
ErrorMessage="Please enter phone number" OnServerValidate="ValidReqPhone"> < /asp:CustomValidator>
< cc1:ValidatorCalloutExtender ID="valieReqPhone2" runat="server"
HighlightCssClass="validatorCalloutHighlight" TargetControlID="cvPhone">
< /cc1:ValidatorCalloutExtender>
< /td>
< /tr>
< tr>
< td>
< span> < /span> Contact Address
< /td>
< td>
< asp:TextBox ID="txtContactAddress" runat="server" MaxLength="100" TabIndex="10"> < /asp:TextBox>
< /td>
< /tr>
< tr>
< td>
< span class=""> < /span> City
< /td>
< td>
< asp:TextBox ID="txtCity" runat="server" MaxLength="25" TabIndex="11"> < /asp:TextBox>
< /td>
< /tr>
< tr>
< td>
< span class=""> < /span> State
< /td>
< td>
< asp:DropDownList ID="ddlState" runat="server" Width="90px" AutoPostBack="True" TabIndex="12">

< /asp:DropDownList>
< /td>
< /tr>
< tr>
< td>
ZIP< /td>
< td>
< asp:TextBox ID="txtZipCode" runat="server" MaxLength="5" TabIndex="12" > < /asp:TextBox>
< cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server"
FilterType="Custom" InvalidChars="A-Z, a-z" TargetControlID="txtZipCode"
ValidChars="1,2,3,4,5,6,7,8,9,0">
< /cc1:FilteredTextBoxExtender>
< asp:RegularExpressionValidator ID="regulaExZipCode" runat="server"
ControlToValidate="txtZipCode" Display="None" EnableClientScript="true"
ErrorMessage="Please enter valid ZIP format (#####)" SetFocusOnError="true"
ValidationExpression="\d{5}"> < /asp:RegularExpressionValidator>
< cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender2" runat="server"
TargetControlID="regulaExZipCode">
< /cc1:ValidatorCalloutExtender>
< /td>
< /tr>
< tr>
< td>
 
< /td>
< /tr>
< tr>
< td>
< asp:ImageButton ID="imbSubmit" runat="server" CausesValidation="True"
ImageUrl="~/images/submitw.gif" onclick="imbSubmit_Click" TabIndex="13"/>
< asp:HiddenField ID="hdnUserId" runat="server" />
< asp:HiddenField ID="hdnOldUserName" runat="server" />
< asp:HiddenField ID="hdnOldEmailId" runat="server" />
< /td>
< /tr>

< /table>
< asp:Label ID="Label4" runat="server" Style="display: none"> < /asp:Label>
< cc1:ModalPopupExtender ID="ModalPopupExtender4" TargetControlID="Label4" CancelControlID="imbOk"
BackgroundCssClass="popupbg" PopupControlID="Div4" runat="server" OnOkScript="OnOK()">
< /cc1:ModalPopupExtender>

< /form>
< /body>
< /html>

-------------------------Server Validate---------------------------------------
protected void ValidateDropdown(object source, ServerValidateEventArgs args)
{
try
{
if (ddlSchool.SelectedValue == "0")
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
catch
{
args.IsValid = false;

}
}
protected void ValidReqPhone(object source, ServerValidateEventArgs args)
{
try
{
if (String.IsNullOrEmpty(txtPhone1.Text) || String.IsNullOrEmpty(txtPhone2.Text) || String.IsNullOrEmpty(txtPhone3.Text))
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
catch
{
args.IsValid = false;

}
}

No comments:

Post a Comment