Application_state
1.web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<sessionState mode="InProc" timeout="20" cookieless="true"></sessionState>
<compilation debug="true" targetFramework="4.5" />
</system.web>
</configuration>
2.webform.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Application_state.WebForm1" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
3.webform.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Application_state
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("The num of users online=" + Application["user"].ToString());
}
}
}
4.global.asax.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
namespace Application_state
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Application["user"] = 0;
}
protected void Session_Start(object sender, EventArgs e)
{
Application.Lock();
Application["user"] = (int) Application["user"]+1;
Application.UnLock();
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Session_End(object sender, EventArgs e)
{
Application.Lock();
Application["user"] = (int)Application["user"] - 1;
Application.UnLock();
}
protected void Application_End(object sender, EventArgs e)
{
}
}
}
cookies
1.web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
2.default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:Button runat="server" ID="btn_create" Text="Create Cookie" OnClick="btn_create_Click" /></td>
<td>
<asp:TextBox runat="server" ID="txt_create"></asp:TextBox></td>
<td>
<asp:Label runat="server" ID="Label1"></asp:Label></td>
</tr>
<tr>
<td>
<asp:Button runat="server" ID="btn_ret" Text="Retrieve Cookie" OnClick="btn_ret_Click" /></td>
<td>
<asp:TextBox runat="server" ID="txt_ret"></asp:TextBox></td>
</tr>
</table>
</div>
</form>
</body>
</html>
3.default.aspx.cs
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)
{
}
protected void btn_create_Click(object sender, EventArgs e)
{
Response.Cookies["name"].Value = txt_create.Text;
Response.Cookies["name"].Expires = DateTime.Now.AddMinutes(1);
Label1.Text = "Cookie Created";
txt_create.Text = "";
}
protected void btn_ret_Click(object sender, EventArgs e)
{
if (Request.Cookies["name"] == null)
{
txt_ret.Text = "No cookie found";
}
else
{
txt_ret.Text = Request.Cookies["name"].Value;
}
}
}
QUERYSTRING
1 wen.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
2.default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>USERNAME </td>
<td>
<asp:TextBox runat="server" ID="txt_unm"></asp:TextBox></td>
</tr>
<tr>
<td>EMAIL </td>
<td>
<asp:TextBox runat="server" ID="txt_email"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Button runat="server" ID="btn_submit" Text="LOGIN" OnClick="btn_submit_Click" /></td>
</tr>
</table>
</div>
</form>
</body>
</html>
3.default.aspx.cs
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)
{
}
protected void btn_submit_Click(object sender, EventArgs e)
{
Response.Redirect("main.aspx?name=" + txt_unm.Text + "&email=" + txt_email.Text);
}
}
4.main.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="main.aspx.cs" Inherits="main" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:Label runat="server" ID="lbl_unm"></asp:Label></td>
<td>
<asp:Label runat="server" ID="lbl_email"></asp:Label></td>
</tr>
</table>
</div>
</form>
</body>
</html>
5.main.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class main : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lbl_unm.Text = "Name = " + Request.QueryString["name"].ToString();
lbl_email.Text = "Email = " + Request.QueryString["email"].ToString();
}
}
session
1.web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<sessionState timeout="2"></sessionState>
</system.web>
</configuration>
2.default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>USERNAME</td>
<td>
<asp:TextBox runat="server" ID="txt_unm"></asp:TextBox></td>
</tr>
<tr>
<td>PASSWORD</td>
<td>
<asp:TextBox runat="server" ID="txt_pass" TextMode="Password"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Button runat="server" ID="btn_login" Text="LOGIN" OnClick="btn_login_Click" /></td>
</tr>
<tr>
<td>
<asp:Label runat="server" ID="lbl"></asp:Label></td>
</tr>
</table>
</div>
</form>
</body>
</html>
3.default.aspx.cs
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)
{
}
protected void btn_login_Click(object sender, EventArgs e)
{
if (txt_unm.Text == "ND" && txt_pass.Text == "ND")
{
Session["uname"] = txt_unm.Text;
Response.Redirect("Main.aspx");
}
else
{
lbl.Text = "Invalid detail";
}
}
}
4.main.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="main.aspx.cs" Inherits="main" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label runat="server" ID="lblname"></asp:Label>
<br />
<asp:Button runat="server" ID="btn_logout" Text="Logout" OnClick="btn_logout_Click" />
</div>
</form>
</body>
</html>
5.main.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class main : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["uname"] == null)
{
Response.Redirect("Login.aspx");
}
else
{
lblname.Text = "Welcome " + Session["uname"].ToString();
}
}
protected void btn_logout_Click(object sender, EventArgs e)
{
Session["uname"] = null;
Response.Redirect("Default.aspx");
}
}
viewstate
1.web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
2.default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td>UserName:</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>Email:</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" ></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" />
</td>
<td>
<asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Restore" /></td>
</tr>
</table>
</form>
</body>
</html>
3.default.aspx.cs
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)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
ViewState["name"] = TextBox1.Text;
ViewState["email"] = TextBox2.Text;
TextBox1.Text = TextBox2.Text = string.Empty;
}
protected void Button3_Click(object sender, EventArgs e)
{
if (ViewState["name"] != null)
{
TextBox1.Text = ViewState["name"].ToString();
}
if (ViewState["email"] != null)
{
TextBox2.Text = ViewState["email"].ToString();
}
}
}
customValidator
1.web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
</configuration>
2.deafult.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="User ID:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server" OnServerValidate="UserCustomValidate"
ControlToValidate="TextBox1"
ErrorMessage="User ID should have atleast a capital, small and digit and should be greater than 6 and less than 25 letters" SetFocusOnError="True"></asp:CustomValidator>
</div>
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" />
</form>
</body>
</html>
3.deafult.aspx.cs
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 UserCustomValidate(object source, ServerValidateEventArgs args)
{
string str = args.Value;
args.IsValid = false;
if (str.Length < 6 || str.Length > 25)
{
return;
}
bool capital = false;
foreach (char ch in str)
{
if (ch >= 'A' && ch <= 'Z')
{
capital = true;
break;
}
}
if (!capital)
{
return;
}
bool lower = false;
foreach (char ch in str)
{
if (ch >= 'a' && ch <= 'z')
{
lower = true;
break;
}
}
if (!lower)
{
return;
}
bool digit = false;
foreach (char ch in str)
{
if (ch >= '0' && ch <= '9')
{
digit = true;
break;
}
}
if (!digit)
{
return;
}
args.IsValid = true;
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
file_upload
1.web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="15360" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="15728640" ></requestLimits>
</requestFiltering>
</security>
</system.webServer>
</configuration>
2.default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>Select File :</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" /></td>
</tr>
<tr>
<td>
<asp:Button ID="btnupload" runat="server" OnClick="btnupload_Click" Text="Upload" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Font-Bold="True"></asp:Label>
</td>
</tr>
</table>
<asp:Image runat="server" ID="img" />
</div>
</form>
</body>
</html>
3.default.aspx.cs
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)
{
}
protected void btnupload_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(Server.MapPath("~/img/") + FileUpload1.FileName);
img.ImageUrl = "~/img/" + FileUpload1.FileName;
Label1.Text = "Image Uploaded Successfully !!";
}
else
{
Label1.Text = "Select image first !!";
}
}
}
login_with_validation_summary
1.web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
</configuration>
2.default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<table>
<tr>
<td>User Name</td>
<td>
<asp:TextBox ID="txt_username" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="user" runat="server" ControlToValidate="txt_username"
ErrorMessage="Please enter a user name" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Password</td>
<td>
<asp:TextBox ID="txt_password" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="pass" runat="server" ControlToValidate="txt_password"
ErrorMessage="Please enter a password" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<br />
<asp:Button ID="Button1" runat="server" Text="login" />
</td>
<td>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="Red" />
<br />
</td>
</tr>
</table>
</form>
</body>
</html>
3.default.aspx.cs
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)
{
}
}
Reg_form_with
1.web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
</configuration>
2.default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="User Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txt_username" runat="server"></asp:TextBox></td>
<td>
<asp:RequiredFieldValidator runat="server" ID="req_unm" ControlToValidate="txt_username" ErrorMessage="Please Enter Username"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>
<asp:Label ID="Label6" runat="server" Text="Email ID"></asp:Label>
</td>
<td>
<asp:TextBox ID="txt_email" runat="server" TextMode="Email"></asp:TextBox></td>
<td>
<asp:RequiredFieldValidator runat="server" ID="req_email" ControlToValidate="txt_email" ErrorMessage="Please Enter EmailID"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator runat="server" ID="reg_email" ControlToValidate="txt_email" ErrorMessage="Please enter emailid in proper format" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Password"></asp:Label></td>
<td>
<asp:TextBox ID="txt_password" runat="server" TextMode="Password"></asp:TextBox></td>
<td>
<asp:RequiredFieldValidator runat="server" ID="req_pass" ControlToValidate="txt_password" ErrorMessage="Please Enter Password"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Confirm Password"></asp:Label></td>
<td>
<asp:TextBox ID="txt_con_pass" runat="server" TextMode="Password"></asp:TextBox></td>
<td>
<asp:RequiredFieldValidator runat="server" ID="req_con_pass" ControlToValidate="txt_con_pass" ErrorMessage="Please Enter Password"></asp:RequiredFieldValidator>
<asp:CompareValidator runat="server" ID="com_val" ControlToValidate="txt_con_pass" ControlToCompare="txt_password" ErrorMessage="password mismatched"></asp:CompareValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="Gender"></asp:Label></td>
<td>
<asp:RadioButton ID="rdb_m" runat="server" GroupName="gender" Text="Male" />
<asp:RadioButton ID="rdb_f" runat="server" GroupName="gender" Text="Female" /></td>
</tr>
<tr>
<td>
<asp:Label ID="Label7" runat="server" Text="Date of Birth"></asp:Label>s</td>
<td>
<asp:TextBox runat="server" ID="txt_bdate" TextMode="Date"></asp:TextBox>
</td>
</tr>
<tr>
<td></td>
<td>
<br />
<asp:Button ID="btn_submit" runat="server" Text="Register" OnClick="btn_submit_Click" />
</td>
</tr>
</table>
<asp:Label ID="message" runat="server" Font-Size="Medium" ForeColor="Red"></asp:Label>
</div>
</form>
<table>
<tr>
<td>
<asp:Label ID="ShowUserNameLabel" runat="server"></asp:Label></td>
<td>
<asp:Label ID="ShowUserName" runat="server"></asp:Label></td>
</tr>
<tr>
<td>
<asp:Label ID="ShowEmailIDLabel" runat="server"></asp:Label></td>
<td>
<asp:Label ID="ShowEmail" runat="server"></asp:Label></td>
</tr>
<tr>
<td>
<asp:Label ID="ShowGenderLabel" runat="server"></asp:Label></td>
<td>
<asp:Label ID="ShowGender" runat="server"></asp:Label></td>
</tr>
<tr>
<td>
<asp:Label ID="lbl_showbdate" runat="server"></asp:Label></td>
<td>
<asp:Label ID="showbdate" runat="server"></asp:Label></td>
</tr>
</table>
</body>
</html>
3.default.aspx.cs
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)
{
}
protected void btn_submit_Click(object sender, EventArgs e)
{
message.Text = "Hello " + txt_username.Text + " ! ";
message.Text = message.Text + " <br/> You have successfuly Registered with the following details.";
ShowUserName.Text = txt_username.Text;
ShowEmail.Text = txt_email.Text;
if (rdb_m.Checked)
{
ShowGender.Text = rdb_m.Text;
}
else ShowGender.Text = rdb_f.Text;
showbdate.Text = txt_bdate.Text;
ShowUserNameLabel.Text = "User Name";
ShowEmailIDLabel.Text = "Email ID";
ShowGenderLabel.Text = "Gender";
lbl_showbdate.Text = "Birth Date";
txt_username.Text = "";
txt_email.Text = "";
rdb_f.Checked = false;
rdb_m.Checked = false;
}
}
Reg_form_without
1. web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
2.default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="User Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txt_username" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="Label6" runat="server" Text="Email ID"></asp:Label>
</td>
<td>
<asp:TextBox ID="txt_email" runat="server" TextMode="Email"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Password"></asp:Label></td>
<td>
<asp:TextBox ID="txt_password" runat="server" TextMode="Password"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Confirm Password"></asp:Label></td>
<td>
<asp:TextBox ID="txt_con_pass" runat="server" TextMode="Password"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="Gender"></asp:Label></td>
<td>
<asp:RadioButton ID="rdb_m" runat="server" GroupName="gender" Text="Male" />
<asp:RadioButton ID="rdb_f" runat="server" GroupName="gender" Text="Female" /></td>
</tr>
<tr>
<td>
<asp:Label ID="Label7" runat="server" Text="Date of Birth"></asp:Label>s</td>
<td>
<asp:TextBox runat="server" ID="txt_bdate" TextMode="Date"></asp:TextBox>
</td>
</tr>
<tr>
<td></td>
<td>
<br />
<asp:Button ID="btn_submit" runat="server" Text="Register" OnClick="btn_submit_Click" />
</td>
</tr>
</table>
<asp:Label ID="message" runat="server" Font-Size="Medium" ForeColor="Red"></asp:Label>
</div>
</form>
<table>
<tr>
<td>
<asp:Label ID="ShowUserNameLabel" runat="server"></asp:Label></td>
<td>
<asp:Label ID="ShowUserName" runat="server"></asp:Label></td>
</tr>
<tr>
<td>
<asp:Label ID="ShowEmailIDLabel" runat="server"></asp:Label></td>
<td>
<asp:Label ID="ShowEmail" runat="server"></asp:Label></td>
</tr>
<tr>
<td>
<asp:Label ID="ShowGenderLabel" runat="server"></asp:Label></td>
<td>
<asp:Label ID="ShowGender" runat="server"></asp:Label></td>
</tr>
<tr>
<td>
<asp:Label ID="lbl_showbdate" runat="server"></asp:Label></td>
<td>
<asp:Label ID="showbdate" runat="server"></asp:Label></td>
</tr>
</table>
</body>
</html>
3.default.aspx.cs
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)
{
}
protected void btn_submit_Click(object sender, EventArgs e)
{
message.Text = "Hello " + txt_username.Text + " ! ";
message.Text = message.Text + " <br/> You have successfuly Registered with the following details.";
ShowUserName.Text = txt_username.Text;
ShowEmail.Text = txt_email.Text;
if (rdb_m.Checked)
{
ShowGender.Text = rdb_m.Text;
}
else ShowGender.Text = rdb_f.Text;
showbdate.Text = txt_bdate.Text;
ShowUserNameLabel.Text = "User Name";
ShowEmailIDLabel.Text = "Email ID";
ShowGenderLabel.Text = "Gender";
lbl_showbdate.Text = "Birth Date";
txt_username.Text = "";
txt_email.Text = "";
rdb_f.Checked = false;
rdb_m.Checked = false;
}
}
Comments
Post a Comment