Registration.aspx
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="registration.aspx.cs" Inherits="registration" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style3
{
height: 22px;
}
</style>
<script type="text/javascript">
function StandardCheck(source, args)
{
var ddlStandards = document.getElementById("<%=ddlStandards.ClientID%>");
var Standard = ddlStandards.options[ddlStandards.selectedIndex].value;
if (Standard == "0")
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
function StatesCheck(source, args)
{
var ddlStates = document.getElementById("<%=ddlStates.ClientID%>");
var States = ddlStates.options[ddlStates.selectedIndex].value;
if (States == "0")
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
function DistrictsCheck(source, args)
{
var ddlDistricts = document.getElementById("<%=ddlDistricts.ClientID%>");
var Districts = ddlDistricts.options[ddlDistricts.selectedIndex].value;
if (Districts == "0")
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
function QuestionCheck(source, args)
{
var ddlSecurityQues = document.getElementById("<%=ddlSecurityQues.ClientID%>");
var Question = ddlSecurityQues.options[ddlSecurityQues.selectedIndex].value;
if (Question == "0")
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
jQuery(document).ready(function() {
{
$("#aspnetForm").validationEngine();
}
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<center>
<div id="div1" runat="server">
<br/>
<br/>
<asp:Label ID="lblRegistration" runat="server" Text="Registration Form" Font-Bold="True" ForeColor="#0066FF" Font-Size="Large"></asp:Label>
<br />
<br />
<table>
<tr>
<td align="left" style="font-weight: bold"> Student Details </td>
</tr>
<tr>
<td align="left">First Name</td>
<td><asp:TextBox ID="txtFirstName" runat="server" Width="200px" CssClass="validate[Enter FirstName]"></asp:TextBox></td>
</tr>
<tr>
<td align="left">Last Name</td>
<td><asp:TextBox ID="txtLastName" runat="server" Width="200px" CssClass="validate[required]"></asp:TextBox></td>
</tr>
<tr>
<td align="left">Father Name</td>
<td><asp:TextBox ID="txtFatherName" runat="server" Width="200px" CssClass="validate[required]" ValidationGroup="d"></asp:TextBox></td>
</tr>
<tr>
<td align="left">Date of Birth</td>
<td><asp:TextBox ID="txtDOB" runat="server" Width="200px" CssClass="validate[required]"></asp:TextBox></td>
</tr>
<tr>
<td align="left" class="style3">Gender</td>
<td class="style3">
<asp:RadioButtonList ID="rbGender" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="1">Male</asp:ListItem>
<asp:ListItem Value="0">Female</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td align="left">Standard</td>
<td><asp:DropDownList ID="ddlStandards" runat="server" Height="26px" Width="200px"></asp:DropDownList></td>
<td><asp:CustomValidator ID="CustomValidator3" runat="server" ErrorMessage="Please Select Standard" ControlToValidate="ddlStandards" ClientValidationFunction="StandardCheck" ValidationGroup="g1" ></asp:CustomValidator></td>
</tr>
<tr>
<td align="left">State</td>
<td><asp:DropDownList ID="ddlStates" runat="server" Height="26px" Width="200px" AutoPostBack="True" onselectedindexchanged="ddlStates_SelectedIndexChanged"></asp:DropDownList></td>
<td><asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Please Select State" ControlToValidate="ddlStates" ClientValidationFunction="StatesCheck" ValidationGroup="g1"></asp:CustomValidator></td>
</tr>
<tr>
<td align="left">District</td>
<td><asp:DropDownList ID="ddlDistricts" runat="server" Height="26px" Width="200px"></asp:DropDownList></td>
<td><asp:CustomValidator ID="CustomValidator2" runat="server" ErrorMessage="Please Select District" ControlToValidate="ddlDistricts" ClientValidationFunction="DistrictsCheck" ValidationGroup="g1"></asp:CustomValidator></td>
</tr>
<tr>
<td align="left">Address</td>
<td><asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine" Width="200px" CssClass="validate[required]" ValidationGroup="d"></asp:TextBox></td>
</tr>
<tr>
<td align="left">Mobile Number</td>
<td><asp:TextBox ID="txtMobile" runat="server" Width="200px" CssClass="validate[required,custom[integer]"></asp:TextBox></td>
</tr>
<tr>
<td align="left">Landline Number</td>
<td><asp:TextBox ID="txtLandline" runat="server" Width="200px" CssClass="validate[required,custom[integer]"></asp:TextBox></td>
</tr>
<tr>
<td align="left">Email Id</td>
<td><asp:TextBox ID="txtEmail" runat="server" Width="200px" CssClass="validate[required,custom[email]"></asp:TextBox></td>
</tr>
Student Login Details
<tr>
<td align="left">Login Name</td>
<td><asp:TextBox ID="txtLoginId" runat="server" CssClass="validate[required]" Width="200px" OnTextChanged="Login_TextChanged" AutoPostBack="true"></asp:TextBox></td>
<td><asp:Label ID="lblerror" runat="server" Text=""></asp:Label></td>
</tr>
<tr>
<td align="left">Password</td>
<td><asp:TextBox ID="txtPassword" runat="server" CssClass="validate[required]" TextMode="Password" Width="200px"></asp:TextBox></td>
</tr>
<tr>
<td align="left">Confirm Password</td>
<td><asp:TextBox ID="txCtPassword" runat="server" CssClass="validate[required]" TextMode="Password" Width="200px"></asp:TextBox> </td>
<td><asp:CompareValidator ID="comp" runat="server" ControlToValidate="txCtPassword" ControlToCompare="txtPassword" ErrorMessage="*Not Matched"/></td>
</tr>
<tr>
<td align="left">Security Question</td>
<td><asp:DropDownList ID="ddlSecurityQues" runat="server" Height="26px" Width="200px"></asp:DropDownList></td>
</tr>
<tr>
<td align="left">Security Answer</td>
<td><asp:TextBox ID="txtSAnswer" runat="server" CssClass="validate[required]" Width="200px"></asp:TextBox></td>
</tr>
<tr>
<td align="left" colspan="2"><asp:CheckBox ID="cbTerms" runat="server" Text="Check All the above Information is correct"/></td>
</tr>
<tr>
<td align="left">
<br/><asp:Button ID="btnSubmit" runat="server" Text="Submit" Width="99px" onclick="btnSubmit_Click" CausesValidation="true"/></td>
<td><asp:Label ID="lblMsg" runat="server" Text=""></asp:Label></td>
</tr>
</table>
<br/>
<br/>
<br/>
<br/>
</div>
</center>
</asp:Content>
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using OnlineAcademicExam_BAO;
public partial class registration : System.Web.UI.Page
{
Register _objReg = new Register();
PropertiesReg _objProperties = new PropertiesReg();
ListItem _objlistitem = new ListItem("--Select--", "0");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
StandardBind();
StateBind();
QuestionBind();
}
lblerror.Text = "";
}
public void Login_TextChanged(object sender,EventArgs e)
{
string loginid = txtLoginId.Text;
int i=_objReg.Check(loginid);
if (i > 0)
{
Response.Write(@"<script language='javascript'>confirm('Already Exist');</script>");
txtLoginId.Text = "";
}
else
{
lblerror.Text = "Available";
lblerror.ForeColor = System.Drawing.Color.Green;
}
}
public void StateBind()
{
DataTable _dtTable = _objReg.LoadState();
if (_dtTable != null && _dtTable.Rows.Count > 0)
{
ddlStates.DataSource = _dtTable;
ddlStates.DataTextField = _dtTable.Columns["statename"].ToString();
ddlStates.DataValueField = _dtTable.Columns["stateid"].ToString();
ddlStates.DataBind();
ddlStates.Items.Insert(0, _objlistitem);
}
}
public void DistrictBind(int stateid)
{
DataTable _dtTable = _objReg.LoadDistrict(stateid);
if (_dtTable != null && _dtTable.Rows.Count > 0)
{
ddlDistricts.DataSource = _dtTable;
ddlDistricts.DataTextField = _dtTable.Columns["DistrictName"].ToString();
ddlDistricts.DataValueField = _dtTable.Columns["DistrictId"].ToString();
ddlDistricts.DataBind();
ddlDistricts.Items.Insert(0, _objlistitem);
}
}
public void QuestionBind()
{
DataTable _dtTable = _objReg.LoadQuestions();
if (_dtTable != null && _dtTable.Rows.Count > 0)
{
ddlSecurityQues.DataSource = _dtTable;
ddlSecurityQues.DataTextField = "SecurityQuestion";
ddlSecurityQues.DataValueField = "SecurityId";
ddlSecurityQues.DataBind();
ddlSecurityQues.Items.Insert(0, _objlistitem);
}
}
public void StandardBind()
{
DataTable _dtTable = _objReg.LoadStandard();
ddlStandards.DataSource = _dtTable;
ddlStandards.DataTextField = "Standard";
ddlStandards.DataValueField = "StandardId";
ddlStandards.DataBind();
ddlStandards.Items.Insert(0,_objlistitem);
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
_objProperties.FirstName = txtFirstName.Text;
_objProperties.LastName = txtLastName.Text;
_objProperties.FatherName = txtFatherName.Text;
_objProperties.Gender = Convert.ToInt32(rbGender.SelectedItem.Value).ToString();
_objProperties.DateofBirth = txtDOB.Text;
_objProperties.Standard = Convert.ToInt32(ddlStandards.SelectedItem.Value);
_objProperties.State = Convert.ToInt32(ddlStates.SelectedItem.Value);
_objProperties.District = Convert.ToInt32(ddlDistricts.SelectedItem.Value);
_objProperties.Address = txtAddress.Text;
_objProperties.MobileNumber = txtMobile.Text;
_objProperties.LandNumber = txtLandline.Text;
_objProperties.Email = txtEmail.Text;
_objProperties.LoginName = txtLoginId.Text;
_objProperties.Password = txtPassword.Text;
_objProperties.SecurityQuestion = Convert.ToInt32(ddlSecurityQues.SelectedItem.Value);
_objProperties.Answer = txtSAnswer.Text;
int i = _objReg.InsertUser(_objProperties);
if (i > 0)
{
// lblMsg.Text = "Register Sucessfully";
Response.Write(@"<script language='javascript'>confirm('Registered Successfully');</script>");
Response.Redirect("login.aspx");
}
else
{
Response.Write(@"<script language='javascript'>alert('Registration Failed');</script>");
}
}
protected void ddlStates_SelectedIndexChanged(object sender, EventArgs e)
{
int i = Convert.ToInt32(ddlStates.SelectedItem.Value);
DistrictBind(i);
}
}
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="registration.aspx.cs" Inherits="registration" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style3
{
height: 22px;
}
</style>
<script type="text/javascript">
function StandardCheck(source, args)
{
var ddlStandards = document.getElementById("<%=ddlStandards.ClientID%>");
var Standard = ddlStandards.options[ddlStandards.selectedIndex].value;
if (Standard == "0")
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
function StatesCheck(source, args)
{
var ddlStates = document.getElementById("<%=ddlStates.ClientID%>");
var States = ddlStates.options[ddlStates.selectedIndex].value;
if (States == "0")
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
function DistrictsCheck(source, args)
{
var ddlDistricts = document.getElementById("<%=ddlDistricts.ClientID%>");
var Districts = ddlDistricts.options[ddlDistricts.selectedIndex].value;
if (Districts == "0")
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
function QuestionCheck(source, args)
{
var ddlSecurityQues = document.getElementById("<%=ddlSecurityQues.ClientID%>");
var Question = ddlSecurityQues.options[ddlSecurityQues.selectedIndex].value;
if (Question == "0")
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
jQuery(document).ready(function() {
{
$("#aspnetForm").validationEngine();
}
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<center>
<div id="div1" runat="server">
<br/>
<br/>
<asp:Label ID="lblRegistration" runat="server" Text="Registration Form" Font-Bold="True" ForeColor="#0066FF" Font-Size="Large"></asp:Label>
<br />
<br />
<table>
<tr>
<td align="left" style="font-weight: bold"> Student Details </td>
</tr>
<tr>
<td align="left">First Name</td>
<td><asp:TextBox ID="txtFirstName" runat="server" Width="200px" CssClass="validate[Enter FirstName]"></asp:TextBox></td>
</tr>
<tr>
<td align="left">Last Name</td>
<td><asp:TextBox ID="txtLastName" runat="server" Width="200px" CssClass="validate[required]"></asp:TextBox></td>
</tr>
<tr>
<td align="left">Father Name</td>
<td><asp:TextBox ID="txtFatherName" runat="server" Width="200px" CssClass="validate[required]" ValidationGroup="d"></asp:TextBox></td>
</tr>
<tr>
<td align="left">Date of Birth</td>
<td><asp:TextBox ID="txtDOB" runat="server" Width="200px" CssClass="validate[required]"></asp:TextBox></td>
</tr>
<tr>
<td align="left" class="style3">Gender</td>
<td class="style3">
<asp:RadioButtonList ID="rbGender" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="1">Male</asp:ListItem>
<asp:ListItem Value="0">Female</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td align="left">Standard</td>
<td><asp:DropDownList ID="ddlStandards" runat="server" Height="26px" Width="200px"></asp:DropDownList></td>
<td><asp:CustomValidator ID="CustomValidator3" runat="server" ErrorMessage="Please Select Standard" ControlToValidate="ddlStandards" ClientValidationFunction="StandardCheck" ValidationGroup="g1" ></asp:CustomValidator></td>
</tr>
<tr>
<td align="left">State</td>
<td><asp:DropDownList ID="ddlStates" runat="server" Height="26px" Width="200px" AutoPostBack="True" onselectedindexchanged="ddlStates_SelectedIndexChanged"></asp:DropDownList></td>
<td><asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Please Select State" ControlToValidate="ddlStates" ClientValidationFunction="StatesCheck" ValidationGroup="g1"></asp:CustomValidator></td>
</tr>
<tr>
<td align="left">District</td>
<td><asp:DropDownList ID="ddlDistricts" runat="server" Height="26px" Width="200px"></asp:DropDownList></td>
<td><asp:CustomValidator ID="CustomValidator2" runat="server" ErrorMessage="Please Select District" ControlToValidate="ddlDistricts" ClientValidationFunction="DistrictsCheck" ValidationGroup="g1"></asp:CustomValidator></td>
</tr>
<tr>
<td align="left">Address</td>
<td><asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine" Width="200px" CssClass="validate[required]" ValidationGroup="d"></asp:TextBox></td>
</tr>
<tr>
<td align="left">Mobile Number</td>
<td><asp:TextBox ID="txtMobile" runat="server" Width="200px" CssClass="validate[required,custom[integer]"></asp:TextBox></td>
</tr>
<tr>
<td align="left">Landline Number</td>
<td><asp:TextBox ID="txtLandline" runat="server" Width="200px" CssClass="validate[required,custom[integer]"></asp:TextBox></td>
</tr>
<tr>
<td align="left">Email Id</td>
<td><asp:TextBox ID="txtEmail" runat="server" Width="200px" CssClass="validate[required,custom[email]"></asp:TextBox></td>
</tr>
Student Login Details
<tr>
<td align="left">Login Name</td>
<td><asp:TextBox ID="txtLoginId" runat="server" CssClass="validate[required]" Width="200px" OnTextChanged="Login_TextChanged" AutoPostBack="true"></asp:TextBox></td>
<td><asp:Label ID="lblerror" runat="server" Text=""></asp:Label></td>
</tr>
<tr>
<td align="left">Password</td>
<td><asp:TextBox ID="txtPassword" runat="server" CssClass="validate[required]" TextMode="Password" Width="200px"></asp:TextBox></td>
</tr>
<tr>
<td align="left">Confirm Password</td>
<td><asp:TextBox ID="txCtPassword" runat="server" CssClass="validate[required]" TextMode="Password" Width="200px"></asp:TextBox> </td>
<td><asp:CompareValidator ID="comp" runat="server" ControlToValidate="txCtPassword" ControlToCompare="txtPassword" ErrorMessage="*Not Matched"/></td>
</tr>
<tr>
<td align="left">Security Question</td>
<td><asp:DropDownList ID="ddlSecurityQues" runat="server" Height="26px" Width="200px"></asp:DropDownList></td>
</tr>
<tr>
<td align="left">Security Answer</td>
<td><asp:TextBox ID="txtSAnswer" runat="server" CssClass="validate[required]" Width="200px"></asp:TextBox></td>
</tr>
<tr>
<td align="left" colspan="2"><asp:CheckBox ID="cbTerms" runat="server" Text="Check All the above Information is correct"/></td>
</tr>
<tr>
<td align="left">
<br/><asp:Button ID="btnSubmit" runat="server" Text="Submit" Width="99px" onclick="btnSubmit_Click" CausesValidation="true"/></td>
<td><asp:Label ID="lblMsg" runat="server" Text=""></asp:Label></td>
</tr>
</table>
<br/>
<br/>
<br/>
<br/>
</div>
</center>
</asp:Content>
Registration.aspx.cs
using System;
using System.Collections;using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using OnlineAcademicExam_BAO;
public partial class registration : System.Web.UI.Page
{
Register _objReg = new Register();
PropertiesReg _objProperties = new PropertiesReg();
ListItem _objlistitem = new ListItem("--Select--", "0");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
StandardBind();
StateBind();
QuestionBind();
}
lblerror.Text = "";
}
public void Login_TextChanged(object sender,EventArgs e)
{
string loginid = txtLoginId.Text;
int i=_objReg.Check(loginid);
if (i > 0)
{
Response.Write(@"<script language='javascript'>confirm('Already Exist');</script>");
txtLoginId.Text = "";
}
else
{
lblerror.Text = "Available";
lblerror.ForeColor = System.Drawing.Color.Green;
}
}
public void StateBind()
{
DataTable _dtTable = _objReg.LoadState();
if (_dtTable != null && _dtTable.Rows.Count > 0)
{
ddlStates.DataSource = _dtTable;
ddlStates.DataTextField = _dtTable.Columns["statename"].ToString();
ddlStates.DataValueField = _dtTable.Columns["stateid"].ToString();
ddlStates.DataBind();
ddlStates.Items.Insert(0, _objlistitem);
}
}
public void DistrictBind(int stateid)
{
DataTable _dtTable = _objReg.LoadDistrict(stateid);
if (_dtTable != null && _dtTable.Rows.Count > 0)
{
ddlDistricts.DataSource = _dtTable;
ddlDistricts.DataTextField = _dtTable.Columns["DistrictName"].ToString();
ddlDistricts.DataValueField = _dtTable.Columns["DistrictId"].ToString();
ddlDistricts.DataBind();
ddlDistricts.Items.Insert(0, _objlistitem);
}
}
public void QuestionBind()
{
DataTable _dtTable = _objReg.LoadQuestions();
if (_dtTable != null && _dtTable.Rows.Count > 0)
{
ddlSecurityQues.DataSource = _dtTable;
ddlSecurityQues.DataTextField = "SecurityQuestion";
ddlSecurityQues.DataValueField = "SecurityId";
ddlSecurityQues.DataBind();
ddlSecurityQues.Items.Insert(0, _objlistitem);
}
}
public void StandardBind()
{
DataTable _dtTable = _objReg.LoadStandard();
ddlStandards.DataSource = _dtTable;
ddlStandards.DataTextField = "Standard";
ddlStandards.DataValueField = "StandardId";
ddlStandards.DataBind();
ddlStandards.Items.Insert(0,_objlistitem);
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
_objProperties.FirstName = txtFirstName.Text;
_objProperties.LastName = txtLastName.Text;
_objProperties.FatherName = txtFatherName.Text;
_objProperties.Gender = Convert.ToInt32(rbGender.SelectedItem.Value).ToString();
_objProperties.DateofBirth = txtDOB.Text;
_objProperties.Standard = Convert.ToInt32(ddlStandards.SelectedItem.Value);
_objProperties.State = Convert.ToInt32(ddlStates.SelectedItem.Value);
_objProperties.District = Convert.ToInt32(ddlDistricts.SelectedItem.Value);
_objProperties.Address = txtAddress.Text;
_objProperties.MobileNumber = txtMobile.Text;
_objProperties.LandNumber = txtLandline.Text;
_objProperties.Email = txtEmail.Text;
_objProperties.LoginName = txtLoginId.Text;
_objProperties.Password = txtPassword.Text;
_objProperties.SecurityQuestion = Convert.ToInt32(ddlSecurityQues.SelectedItem.Value);
_objProperties.Answer = txtSAnswer.Text;
int i = _objReg.InsertUser(_objProperties);
if (i > 0)
{
// lblMsg.Text = "Register Sucessfully";
Response.Write(@"<script language='javascript'>confirm('Registered Successfully');</script>");
Response.Redirect("login.aspx");
}
else
{
Response.Write(@"<script language='javascript'>alert('Registration Failed');</script>");
}
}
protected void ddlStates_SelectedIndexChanged(object sender, EventArgs e)
{
int i = Convert.ToInt32(ddlStates.SelectedItem.Value);
DistrictBind(i);
}
}
No comments:
Post a Comment