.cs code for registration form
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
txtName.Focus();
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
//Code for Name
lblDispName.Text = txtName.Text;
//Code for Password
lblDispPwd.Text = txtPwd.Text;
//Code for Confirm Password
lblDispConfPwd.Text = txtConfPwd.Text;
//Code for Email
lblDispEmail.Text = txtEmail.Text;
//Code for Radioboxes
if (rbMale.Checked==true)
{
lblDispGender.Text = rbMale.Text;
}
else if (rbFemale.Checked==true)
{
lblDispGender.Text = rbFemale.Text;
}
//Code for Checkboxes
string check = "";
if (cbCricket.Checked)
check +=cbCricket.Text + " ";
if(cbSwimming.Checked)
check += cbSwimming.Text + " ";
if(cbPool.Checked)
check += cbPool.Text;
lblDispHobbies.Text = check;
//Code for Dropdownlist
//Method 1
//DateTime dt = new DateTime();
//dt = System.DateTime.Now;
//int day = dt.Day;
//int month = dt.Month;
//int year = dt.Year;
//ddlDay.SelectedValue = day.ToString();
//ddlMonth.SelectedValue = month.ToString();
//ddlYear.SelectedValue = year.ToString();
//Method 2
DateTime dt=new DateTime();
string sdate = dt.ToString();
string smonth = dt.ToString();
string syear = dt.ToString();
ddlDay.SelectedValue = sdate;
ddlMonth.SelectedValue = smonth;
ddlYear.SelectedValue = syear;
lblDispDOB.Text = ddlDay.SelectedValue + "/" + ddlMonth.SelectedValue + "/" + ddlYear.SelectedValue;
//Convert.ToDateTime(lblDispDOB.Text.ToString());
//Note: but be sure if any one select Feb and day = 30 or 31 then it will show error....
//Code for Address
lblDispAddr.Text = txtAddr.Text;
}
}
.aspx code for registration form
<%@ 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 runat="server">
<title></title>
<link rel="stylesheet" href="Styles/ValidationStyle.css" type="text/css" />
<script src="http://YOURJQUERYPATH/js/jquery.js" type="text/javascript"></script>
<script src="http://YOURJQUERYPATH/js/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">
function isNumberKey(textboxvalue)
{
evt=textboxvalue.text;
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
textboxvalue.text="Enter in Integer Only";
return false;
return true;
}
</script>
<style type="text/css">
#mainBody
{
width: 100%;
height: 100%;
background-color:Maroon;
}
#form1
{
width: 1000px;
height: 1050px;
background-color:Silver;
border:1px solid black;
margin-left:12%;
margin-top:10px;
}
.maindiv
{
width:900;
height: 1050px;
}
.divTable1
{
width: 400px;
height: 455px;
margin-top:38px;
margin-right:5%;
border:1px solid black;
float:right;
}
.divTable2
{
width: 400px;
height: 400px;
margin-right: 5%;
margin-top: 20px;
border:1px solid black;
float:right;
}
.divTable1 .table1
{
width: 400px;
height: 455px;
border:1px solid black;
background-color:Yellow;
}
.divTable2 .table2
{
width: 400px;
height: 400px;
border:1px solid black;
background-color:Lime;
}
.divTable1 .table1 .input
{
text-shadow: 1px 1px 0 #FFFFFF;
text-align: center;
}
.style1
{
color: #FF0000;
}
</style>
</head>
<body id="mainBody">
<form id="form1" runat="server">
<div class="maindiv">
<div class="divTable1">
<table class="table1">
<tr>
<td colspan="2" style="text-align: center">
<h1>Registration Form</h1>
</td>
</tr>
<tr>
<td>
</td>
<td class="style1" style="text-align: right">
*All Fields are required</td>
</tr>
<tr>
<td>
<asp:Label ID="lblName" runat="server" Text="Name"></asp:Label>
</td>
<td class="input">
<asp:TextBox ID="txtName" runat="server" Width="150px" TabIndex="1"
ontextchanged="txtName_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtName" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblPwd" runat="server" Text="Pasword"></asp:Label>
</td>
<td class="input">
<asp:TextBox ID="txtPwd" runat="server" Width="150px" TextMode="Password"
TabIndex="2"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtPwd" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblConfPwd" runat="server" Text="Confirm Password"></asp:Label>
</td>
<td class="input">
<asp:TextBox ID="txtConfPwd" runat="server" Width="150px" TextMode="Password"
TabIndex="3"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtConfPwd" ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ErrorMessage="Pwd Not Matching" ControlToCompare="txtPwd"
ControlToValidate="txtConfPwd"></asp:CompareValidator>
</td>
</tr>
<tr>
<td class="input">
<asp:Label ID="lblEmail" runat="server" Text="Email"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtEmail" runat="server" Width="150px" TabIndex="4"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtEmail" ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtEmail" ErrorMessage="Email should be in correct format"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblGender" runat="server" Text="Gender"></asp:Label>
</td>
<td>
<table>
<tr>
<td>
<asp:RadioButton ID="rbMale" runat="server" Text="Male" TabIndex="5" GroupName="g"
oncheckedchanged="rbMale_CheckedChanged" />
</td>
<td>
<asp:RadioButton ID="rbFemale" runat="server" Text="Female" TabIndex="6" GroupName="g" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblHobbies" runat="server" Text="Hobbies"></asp:Label>
</td>
<td>
<table>
<tr>
<td>
<asp:CheckBox ID="cbCricket" runat="server" Text="Cricket" TabIndex="7" />
</td>
<td>
<asp:CheckBox ID="cbSwimming" runat="server" Text="Swimming" TabIndex="8" />
</td>
<td>
<asp:CheckBox ID="cbPool" runat="server" Text="Pool" TabIndex="9" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblDOB" runat="server" Text="DOB"></asp:Label>
</td>
<td>
<table>
<tr>
<td>
<asp:DropDownList ID="ddlDay" runat="server" TabIndex="10">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>9</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
<asp:ListItem>13</asp:ListItem>
<asp:ListItem>14</asp:ListItem>
<asp:ListItem>15</asp:ListItem>
<asp:ListItem>16</asp:ListItem>
<asp:ListItem>17</asp:ListItem>
<asp:ListItem>18</asp:ListItem>
<asp:ListItem>19</asp:ListItem>
<asp:ListItem>20</asp:ListItem>
<asp:ListItem>21</asp:ListItem>
<asp:ListItem>22</asp:ListItem>
<asp:ListItem>23</asp:ListItem>
<asp:ListItem>24</asp:ListItem>
<asp:ListItem>25</asp:ListItem>
<asp:ListItem>26</asp:ListItem>
<asp:ListItem>27</asp:ListItem>
<asp:ListItem>28</asp:ListItem>
<asp:ListItem>29</asp:ListItem>
<asp:ListItem>30</asp:ListItem>
<asp:ListItem>31</asp:ListItem>
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="ddlMonth" runat="server" TabIndex="11">
<asp:ListItem>Jan</asp:ListItem>
<asp:ListItem>Feb</asp:ListItem>
<asp:ListItem>Mar</asp:ListItem>
<asp:ListItem>Apr</asp:ListItem>
<asp:ListItem>May</asp:ListItem>
<asp:ListItem>Jun</asp:ListItem>
<asp:ListItem>Jul</asp:ListItem>
<asp:ListItem>Aug</asp:ListItem>
<asp:ListItem>Sep</asp:ListItem>
<asp:ListItem>Oct</asp:ListItem>
<asp:ListItem>Nov</asp:ListItem>
<asp:ListItem>Dec</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="ddlYear" runat="server" TabIndex="12">
<asp:ListItem>2006</asp:ListItem>
<asp:ListItem>2007</asp:ListItem>
<asp:ListItem>2008</asp:ListItem>
<asp:ListItem>2009</asp:ListItem>
<asp:ListItem>2010</asp:ListItem>
<asp:ListItem>2011</asp:ListItem>
<asp:ListItem>2012</asp:ListItem>
<asp:ListItem>2013</asp:ListItem>
<asp:ListItem>2014</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblAddr" runat="server" Text="Address"></asp:Label>
</td >
<td class="input">
<asp:TextBox ID="txtAddr" runat="server" TextMode="MultiLine" Width="222px"
TabIndex="13"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="txtAddr" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" Width="104px"
onclick="btnSubmit_Click" BackColor="#CC99FF" TabIndex="14" />
</td>
</tr>
</table>
</div>
<br />
<div class ="divTable2">
<table class="table2">
<tr>
<td >
<asp:Label ID="Lable9" runat="server" Text="Name"></asp:Label>
</td>
<td>
<asp:Label ID="lblDispName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label10" runat="server" Text="Pasword"></asp:Label>
</td>
<td>
<asp:Label ID="lblDispPwd" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label11" runat="server" Text="Confirm Password"></asp:Label>
</td>
<td>
<asp:Label ID="lblDispConfPwd" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label12" runat="server" Text="Email"></asp:Label>
</td>
<td>
<asp:Label ID="lblDispEmail" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label13" runat="server" Text="Gender"></asp:Label>
</td>
<td>
<asp:Label ID="lblDispGender" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label14" runat="server" Text="Hobbies"></asp:Label>
</td>
<td>
<asp:Label ID="lblDispHobbies" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label15" runat="server" Text="DOB"></asp:Label>
</td>
<td>
<asp:Label ID="lblDispDOB" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label16" runat="server" Text="Address"></asp:Label>
</td>
<td>
<asp:Label ID="lblDispAddr" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</div>
</form>
</body>
</html>