How to check If checkbox Is checked in asp.net
Check If checkbox is checked in asp.net using C#:
CheckBox is an asp.netweb server control present in .net platform. Checkbox control allow to user (web site visitor) to
check (select) a particular item on page as like true or false condition. so the checkbox control create a square box on
web page that allow user to switch
between a true or false condition. In this asp.net tutorial we also provide many post related to check box like "how to use check box with in gridview control in asp.net" and how to use check box in gridview header Example and "how to check validation of checkbox control" and using checkbox in asp.net example.
. Html CheckBox controls using jQuery
. Html CheckBox controls using jQuery
Checkbox control properties:
the checkbox control has many properties that gives to facility to user to change style such as BackColor, BorderColor,BorderStyle, CssClass, BorderWidth, EnableTheming, SkinID, Font, Width,Height, ForeColor, ToolTip,etc.Check If checkbox is checked:
if we want to determine whether checkbox is selected then we need to use the
checkbox Checked property. checkbox
AutoPostBack property value true enable automatic refers the web page when
selected.Asp.net developers can write an event handler for CheckedChanged
event.
Example of checkbox.aspx page code in asp.net :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Exampleofcheckbox.aspx.cs" Inherits="Exampleofcheckbox" %>
<!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 align="center">
<h1> Example of Checkbox in asp.net</h1>
<asp:CheckBox ID="CheckBox1"
runat="server"
Font-Size="Large"
Text="Select this "
/>
<br />
<br />
<asp:Label ID="Label1" runat="server"
ForeColor="Red"></asp:Label>
<br />
<br />
<asp:Button ID="Button1"
runat="server"
Font-Bold="True"
Font-Size="Large"
Height="41px"
onclick="Button1_Click"
Text="Submite"
Width="94px"
/>
</div>
</form>
</body>
Checkbox.aspx page C# code in asp.net :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Exampleofcheckbox
: System.Web.UI.Page
{
protected void
Page_Load(object sender, EventArgs e)
{
}
protected void
Button1_Click(object sender, EventArgs e)
{
if (CheckBox1.Checked == true)
{
Label1.Text = "check box
selected.";
}
else
{
Label1.Text = "check box not
selected.";
}
}
}
Comments
Post a Comment