![]() |
| Add caption |
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table>
<tr>
<td>name</td>
<td><asp:TextBox runat="server" ID="txtname"></asp:TextBox></td>
</tr>
<tr>
<td>Username</td>
<td><asp:TextBox runat="server" ID="txtusername"></asp:TextBox></td>
</tr>
<tr>
<td>password</td>
<td><asp:TextBox runat ="server" ID="txtpassword"></asp:TextBox></td>
</tr>
<tr>
<td>Confirm Password</td>
<td>
<asp:TextBox ID="txtrepwd" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>Gender</td>
<td>
<asp:RadioButtonList ID="rdbgender" RepeatDirection="Horizontal" ValidationGroup="rdbgender" runat="server">
<asp:ListItem Text ="male" Value ="male"></asp:ListItem>
<asp:ListItem Text ="female" Value ="female"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td>Date of Birth</td>
<td><asp:TextBox runat ="server" ID="txtdateofbirth"></asp:TextBox></td>
<td>
<asp:ImageButton ID="imgcalender" ImageUrl="~/images/download.png" Height ="50"
Width="40" runat="server" onclick="imgcalender_Click" /><asp:Calendar ID="Calendar1"
runat="server" BackColor="White" BorderColor="#3366CC"
BorderWidth="1px" CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana"
Font-Size="8pt" ForeColor="#003399" Height="200px"
onselectionchanged="Calendar1_SelectionChanged" Width="220px">
<DayHeaderStyle BackColor="#99CCCC" ForeColor="#336666" Height="1px" />
<NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" />
<OtherMonthDayStyle ForeColor="#999999" />
<SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />
<TitleStyle BackColor="#003399" BorderColor="#3366CC" BorderWidth="1px"
Font-Bold="True" Font-Size="10pt" ForeColor="#CCCCFF" Height="25px" />
<TodayDayStyle BackColor="#99CCCC" ForeColor="White" />
<WeekendDayStyle BackColor="#CCCCFF" />
</asp:Calendar>
</td>
</tr>
<tr>
<td>Qualification</td>
<td>
<asp:CheckBoxList ID="cblqualification" RepeatColumns="3" RepeatDirection ="Horizontal" runat="server">
<asp:ListItem Text ="BCA" Value ="BCA"></asp:ListItem>
<asp:ListItem Text ="MCA" Value ="MCA"></asp:ListItem>
<asp:ListItem Text ="BA" Value ="BA"></asp:ListItem>
<asp:ListItem Text ="BBA" Value ="BBA"></asp:ListItem>
<asp:ListItem Text ="MBA" Value ="MBA"></asp:ListItem>
</asp:CheckBoxList>
</tr>
<tr>
<td>country</td>
<td>
<asp:DropDownList ID="ddlcountry" runat="server"
>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>State</td>
<td>
<asp:DropDownList ID="ddlstate" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" ></asp:Label></td>
<td>
<asp:Button ID="btnsubmit" runat="server" Text="register" onclick="btnsubmit_Click1"
/></td>
</tr></table>
</asp:Content>
User Registration.aspx.cs
using System;using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class userDeatils : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["furniturecompandy"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Calendar1.Visible = false;
Bind_ddlcountry();
bind_state();
}
}
protected void Bind_ddlcountry()
{
con.Open();
SqlDataAdapter da =new SqlDataAdapter (" select * from country", con);
DataSet ds = new DataSet();
da.Fill(ds);
ddlcountry.DataSource = ds;
ddlcountry.DataTextField = "countryName";
ddlcountry.DataValueField = "countryId";
ddlcountry.DataBind();
con.Close();
}
protected void bind_state()
{
con.Open();
SqlCommand cmd = new SqlCommand(" select * from state ", con);
DataSet ds = new DataSet();
ddlstate.DataSource = cmd.ExecuteReader();
ddlstate.DataTextField = "statename";
ddlstate.DataValueField = "stateid";
ddlstate.DataBind();
con.Close();
}
protected void imgcalender_Click(object sender, ImageClickEventArgs e)
{
Calendar1.Visible = true;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
txtdateofbirth.Text = Calendar1.SelectedDate.ToString("d");
Calendar1.Visible = false;
}
protected void btnsubmit_Click1(object sender, EventArgs e)
{
string qualificationlist = string.Empty;
foreach (ListItem qualification in cblqualification.Items)
{
if (qualification.Selected)
qualificationlist += string.Format("{0}", qualification.Text);
}
con.Open();
SqlCommand cmd = new SqlCommand("insert into registration values(@name,@username,@password,@gender,@dateofbirth,@qualification,@country,@state,getdate())", con);
cmd.Parameters.AddWithValue("@name", txtname.Text.Trim());
cmd.Parameters.AddWithValue("@username", txtusername.Text.Trim());
cmd.Parameters.AddWithValue("@password", txtpassword.Text.Trim());
cmd.Parameters.AddWithValue("@gender", rdbgender.SelectedValue);
cmd.Parameters.AddWithValue("@dateofbirth", txtdateofbirth.Text);
cmd.Parameters.AddWithValue("@qualification", qualificationlist);
cmd.Parameters.AddWithValue("@country", ddlcountry.SelectedValue);
cmd.Parameters.AddWithValue("@state", ddlstate.SelectedValue);
cmd.ExecuteNonQuery();
Response.Write("<script>alert('record inserted successfully')</script>");
con.Close();
txtname.Text = "";
txtusername.Text = "";
txtpassword.Text = "";
rdbgender.Text = "";
txtdateofbirth.Text = "";
}
}

Comments
Post a Comment