Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="WebFormControls.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 74px;
}
.auto-style3 {
margin-top: 0px;
}
.auto-style4 {
width: 74px;
height: 2px;
}
.auto-style5 {
height: 2px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td class="auto-style2">
<asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
</td> <td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label2" runat="server" Text="Gender"></asp:Label>
</td> <td>
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
AutoPostBack="True">
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label3" runat="server" Text="Country"></asp:Label>
</td> <td>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>India</asp:ListItem>
<asp:ListItem>Canada</asp:ListItem>
<asp:ListItem>USA</asp:ListItem>
<asp:ListItem>Japan</asp:ListItem>
<asp:ListItem>Australia</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label4" runat="server" Text="Hobbies"></asp:Label>
</td> <td>
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem>Reading</asp:ListItem>
<asp:ListItem>Writting</asp:ListItem>
<asp:ListItem>Playing</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td class="auto-style4"></td>
<td class="auto-style5"></td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td>
<asp:Button ID="Button1" runat="server" BackColor="#0066FF"
OnClick="Button1_Click" Text="Submit" Width="75px" CssClass="auto-style3"
Height="41px" />
</td>
</tr>
</table>
</div>
<p>
<asp:Label ID="Label5" runat="server" Text=""></asp:Label>
</p>
<asp:Label ID="Label6" runat="server" Text=""></asp:Label>
<p>
<asp:Label ID="Label7" runat="server" Text=""></asp:Label>
</p>
<asp:Label ID="Label8" runat="server" Text=""></asp:Label>
</form>
</body>
</html>
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebFormControls
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Label5.Text = "Name :" + TextBox1.Text;
Label6.Text = "Gender :" + RadioButtonList1.Text;
Label7.Text = "Country :" + DropDownList1.Text;
foreach(ListItem a in CheckBoxList1.Items)
{
if(a.Selected==true)
{
Label8.Text = "Hobbies : "+a.Text + "<br>";
}
}
}
}
}
0 Comments