<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Checkbox Tutorial</h2>
<strong>Language</strong>
<asp:CheckBox ID="chkbHindi" runat="server" Text="Hindi" />
<asp:CheckBox ID="chkbEnglish" runat="server" Text="English" />
<asp:CheckBox ID="chkbMarathi" runat="server" Text="Marathi" />
<asp:CheckBox ID="chkbMarwadi" runat="server" Text="Marwadi/Rajasthani" />
<asp:CheckBox ID="chkbGujrati" runat="server" Text="Gujrati" />
</div>
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Select Language & Submit"/>
<br />
<br />
<asp:Label ID="lbllang" runat="server" Text="[Your Language]"></asp:Label>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class checkbox_sample : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string result = string.Empty;
if (chkbEnglish.Checked == true)
{
result = chkbEnglish.Text;
}
if (chkbGujrati.Checked == true)
{
result = result +"</br>"+ chkbGujrati.Text;
}
if (chkbHindi.Checked == true)
{
result = result + "</br>" + chkbHindi.Text;
}
if (chkbMarathi.Checked == true)
{
result = result + "</br>" + chkbMarathi.Text;
}
if (chkbMarwadi.Checked == true)
{
result = result + "</br>" + chkbMarwadi.Text;
}
lbllang.Text = result;
}
}
No comments:
Post a Comment