WEB-CONFIG FILE:
<add name="reg" connectionString="Data Source=AAGNA-PC\SQLEXPRESS;Initial Catalog=sqlcon;User id=;Password=; Integrated Security=SSPI"/>
CSS-FOR FORM STYLE NAMED MAIN.CSS:
.lab{ float:left; width:20%; font-family:Verdana; font-size:12px;}
.labn{ font-family:Verdana; font-size:12px;}
.head{ font-family:Verdana; font-size:18px; color:red; padding-left:200px;}
.bor{ border:1px dashed #000; width:600px; padding-left:100px; padding-top:10px;}
#container{ width:700px; margin:0 auto 0 auto;}
.textarea {
-webkit-transition: all 0.30s ease-in-out;
-moz-transition: all 0.30s ease-in-out;
-ms-transition: all 0.30s ease-in-out;
-o-transition: all 0.30s ease-in-out;
outline: none;
/*padding: 3px 0px 3px 3px;
margin: 5px 1px 3px 0px;*/
border: 1px solid #DDDDDD; width:200px; height:35px;
}
.textarea:focus {
box-shadow: 0 0 5px rgba(81, 203, 238, 1);
/*padding: 3px 0px 3px 3px;
margin: 5px 1px 3px 0px;*/
border: 1px solid rgba(81, 203, 238, 1);
}
.button {
border: 1px solid #DDD;
border-radius: 3px;
text-shadow: 0 1px 1px white;
-webkit-box-shadow: 0 1px 1px #fff;
-moz-box-shadow: 0 1px 1px #fff;
box-shadow: 0 1px 1px #fff;
font: bold 11px Sans-Serif;
padding: 6px 10px;
white-space: nowrap;
vertical-align: middle;
color: #666;
background: transparent;
cursor: pointer;
width:150px; height:35px;
}
.button:hover, .button:focus {
border-color: #999;
background: -webkit-linear-gradient(top, white, #E0E0E0);
background: -moz-linear-gradient(top, white, #E0E0E0);
background: -ms-linear-gradient(top, white, #E0E0E0);
background: -o-linear-gradient(top, white, #E0E0E0);
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.25), inset 0 0 3px #fff;
-moz-box-shadow: 0 1px 2px rgba(0,0,0,0.25), inset 0 0 3px #fff;
box-shadow: 0 1px 2px rgba(0,0,0,0.25), inset 0 0 3px #fff;
}
.button:active {
border: 1px solid #AAA;
border-bottom-color: #CCC;
border-top-color: #999;
-webkit-box-shadow: inset 0 1px 2px #aaa;
-moz-box-shadow: inset 0 1px 2px #aaa;
box-shadow: inset 0 1px 2px #aaa;
background: -webkit-linear-gradient(top, #E6E6E6, gainsboro);
background: -moz-linear-gradient(top, #E6E6E6, gainsboro);
background: -ms-linear-gradient(top, #E6E6E6, gainsboro);
background: -o-linear-gradient(top, #E6E6E6, gainsboro);
}
.but{ padding-left:130px;}
IN ASPX-FILE
<div id="container">
<div class="head">Registeration form</div><br />
<form id="form1" runat="server">
<div class="bor">
<label class="lab">name</label><asp:TextBox ID="TextBox1" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">email</label><asp:TextBox ID="TextBox2" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">password</label><asp:TextBox ID="TextBox9" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">first name</label><asp:TextBox ID="TextBox3" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">last name</label><asp:TextBox ID="TextBox4" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">mobile number</label><asp:TextBox ID="TextBox5" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">state</label>
<asp:TextBox ID="TextBox6" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">country</label><asp:TextBox ID="TextBox7" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">area</label><asp:TextBox ID="TextBox8" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">gender</label>
<asp:RadioButtonList CssClass="labn"
ID="RadioButtonList1" runat="server">
<asp:ListItem>male</asp:ListItem>
<asp:ListItem>female</asp:ListItem>
</asp:RadioButtonList>
<br />
<div class="but"><asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" CssClass="button"/></div>
<asp:Label ID="lblr" runat="server"></asp:Label><br />
</div>
</form>
</div>
IN ASPX.CS FILE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
public partial class Default2 : System.Web.UI.Page
{
static string strconn = ConfigurationManager.ConnectionStrings["reg"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strconn);
SqlCommand insrt = new SqlCommand("insert into tb_reg (username,email,password,firstname,lastname,mobilenumber,state,country,area,gender) values ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox9.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','"+ RadioButtonList1.Text +"')",con);
con.Open();
insrt.ExecuteNonQuery();
//int arun;
//SqlCommand sel = new SqlCommand("select * from tb_reg");
//SqlDataAdapter da = new SqlDataAdapter(sel);
//DataTable dt = new DataTable();
//da.Fill(dt);
//if (dt.Rows.Count > 0)
//{
// lblr.Text = "register sucess";
//}
//else
//{
// lblr.Text = "register failed";
//}
lblr.Text = "register sucess!!!";
con.Close();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox9.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
TextBox9.Text = "";
}
}
DATABASE-FILE:
USE [sqlcon]
GO
/****** Object: Table [dbo].[tb_reg] Script Date: 11/28/2012 11:27:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tb_reg](
[username] [varchar](50) NULL,
[email] [varchar](50) NULL,
[password] [varchar](50) NULL,
[firstname] [varchar](50) NULL,
[lastname] [varchar](50) NULL,
[mobilenumber] [bigint] NULL,
[state] [varchar](50) NULL,
[country] [varchar](50) NULL,
[area] [varchar](50) NULL,
[gender] [varchar](50) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
OUTPUT:
<add name="reg" connectionString="Data Source=AAGNA-PC\SQLEXPRESS;Initial Catalog=sqlcon;User id=;Password=; Integrated Security=SSPI"/>
CSS-FOR FORM STYLE NAMED MAIN.CSS:
.lab{ float:left; width:20%; font-family:Verdana; font-size:12px;}
.labn{ font-family:Verdana; font-size:12px;}
.head{ font-family:Verdana; font-size:18px; color:red; padding-left:200px;}
.bor{ border:1px dashed #000; width:600px; padding-left:100px; padding-top:10px;}
#container{ width:700px; margin:0 auto 0 auto;}
.textarea {
-webkit-transition: all 0.30s ease-in-out;
-moz-transition: all 0.30s ease-in-out;
-ms-transition: all 0.30s ease-in-out;
-o-transition: all 0.30s ease-in-out;
outline: none;
/*padding: 3px 0px 3px 3px;
margin: 5px 1px 3px 0px;*/
border: 1px solid #DDDDDD; width:200px; height:35px;
}
.textarea:focus {
box-shadow: 0 0 5px rgba(81, 203, 238, 1);
/*padding: 3px 0px 3px 3px;
margin: 5px 1px 3px 0px;*/
border: 1px solid rgba(81, 203, 238, 1);
}
.button {
border: 1px solid #DDD;
border-radius: 3px;
text-shadow: 0 1px 1px white;
-webkit-box-shadow: 0 1px 1px #fff;
-moz-box-shadow: 0 1px 1px #fff;
box-shadow: 0 1px 1px #fff;
font: bold 11px Sans-Serif;
padding: 6px 10px;
white-space: nowrap;
vertical-align: middle;
color: #666;
background: transparent;
cursor: pointer;
width:150px; height:35px;
}
.button:hover, .button:focus {
border-color: #999;
background: -webkit-linear-gradient(top, white, #E0E0E0);
background: -moz-linear-gradient(top, white, #E0E0E0);
background: -ms-linear-gradient(top, white, #E0E0E0);
background: -o-linear-gradient(top, white, #E0E0E0);
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.25), inset 0 0 3px #fff;
-moz-box-shadow: 0 1px 2px rgba(0,0,0,0.25), inset 0 0 3px #fff;
box-shadow: 0 1px 2px rgba(0,0,0,0.25), inset 0 0 3px #fff;
}
.button:active {
border: 1px solid #AAA;
border-bottom-color: #CCC;
border-top-color: #999;
-webkit-box-shadow: inset 0 1px 2px #aaa;
-moz-box-shadow: inset 0 1px 2px #aaa;
box-shadow: inset 0 1px 2px #aaa;
background: -webkit-linear-gradient(top, #E6E6E6, gainsboro);
background: -moz-linear-gradient(top, #E6E6E6, gainsboro);
background: -ms-linear-gradient(top, #E6E6E6, gainsboro);
background: -o-linear-gradient(top, #E6E6E6, gainsboro);
}
.but{ padding-left:130px;}
IN ASPX-FILE
<div id="container">
<div class="head">Registeration form</div><br />
<form id="form1" runat="server">
<div class="bor">
<label class="lab">name</label><asp:TextBox ID="TextBox1" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">email</label><asp:TextBox ID="TextBox2" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">password</label><asp:TextBox ID="TextBox9" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">first name</label><asp:TextBox ID="TextBox3" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">last name</label><asp:TextBox ID="TextBox4" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">mobile number</label><asp:TextBox ID="TextBox5" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">state</label>
<asp:TextBox ID="TextBox6" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">country</label><asp:TextBox ID="TextBox7" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">area</label><asp:TextBox ID="TextBox8" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">gender</label>
<asp:RadioButtonList CssClass="labn"
ID="RadioButtonList1" runat="server">
<asp:ListItem>male</asp:ListItem>
<asp:ListItem>female</asp:ListItem>
</asp:RadioButtonList>
<br />
<div class="but"><asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" CssClass="button"/></div>
<asp:Label ID="lblr" runat="server"></asp:Label><br />
</div>
</form>
</div>
IN ASPX.CS FILE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
public partial class Default2 : System.Web.UI.Page
{
static string strconn = ConfigurationManager.ConnectionStrings["reg"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strconn);
SqlCommand insrt = new SqlCommand("insert into tb_reg (username,email,password,firstname,lastname,mobilenumber,state,country,area,gender) values ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox9.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','"+ RadioButtonList1.Text +"')",con);
con.Open();
insrt.ExecuteNonQuery();
//int arun;
//SqlCommand sel = new SqlCommand("select * from tb_reg");
//SqlDataAdapter da = new SqlDataAdapter(sel);
//DataTable dt = new DataTable();
//da.Fill(dt);
//if (dt.Rows.Count > 0)
//{
// lblr.Text = "register sucess";
//}
//else
//{
// lblr.Text = "register failed";
//}
lblr.Text = "register sucess!!!";
con.Close();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox9.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
TextBox9.Text = "";
}
}
DATABASE-FILE:
USE [sqlcon]
GO
/****** Object: Table [dbo].[tb_reg] Script Date: 11/28/2012 11:27:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tb_reg](
[username] [varchar](50) NULL,
[email] [varchar](50) NULL,
[password] [varchar](50) NULL,
[firstname] [varchar](50) NULL,
[lastname] [varchar](50) NULL,
[mobilenumber] [bigint] NULL,
[state] [varchar](50) NULL,
[country] [varchar](50) NULL,
[area] [varchar](50) NULL,
[gender] [varchar](50) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
OUTPUT:
No comments:
Post a Comment