How to use AutoPostBack with CheckBox in ASP.Net

In this Checkbox control ASP.Net Example we are going to learn about AutoPostBack Property of Checkbox control.

- The AutoPostBack property of the ASP.Net CheckBox control provides the functionality to allow the server side post back event of the web page when user clicks the checkbox control to change its checked state.

STEP 1 – Design the ASP.Net web form like :

 <table border=”1″ bordercolor=”#000000″ style=”z-index: 100; left: 272px; position: absolute;
top: 72px”>
<tr>
<td colspan=”3″ style=”width: 582px”>
<asp:Image ID=”Image1″ runat=”server” ImageUrl=”http://meeraacademy.com/wp-content/themes/elemin/uploads/logo/meeralogo.gif” /></td>
</tr>
<tr>
<td colspan=”3″ rowspan=”2″ style=”width: 582px; height: 21px; text-align: center”>
<table>
<tr>
<td colspan=”2″ style=”height: 30px”>
<strong><span style=”font-size: 14pt”>
Check/Uncheck Checkbox with <span style=”color: #cc0000″>
AutoPostBack</span></span></strong>
</td>
</tr>
<tr>
<td style=”width: 181px; height: 24px; text-align: right;”>
</td>
<td style=”width: 255px; height: 24px;”>
&nbsp;<asp:CheckBox ID=”CheckBox1″ runat=”server” Text=”CheckBox” AutoPostBack=”True” OnCheckedChanged=”CheckBox1_CheckedChanged” /></td>
</tr>
<tr>
<td style=”width: 181px; height: 24px; text-align: right”>
</td>
<td style=”width: 255px; height: 24px”>
<asp:Label ID=”lblanswer” runat=”server”></asp:Label></td>
</tr>
<tr>
<td style=”width: 181px”>
</td>
<td style=”width: 255px”>
</td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
</table>

- The ASP.Net Checkbox AutoPostBack Example output is :

AutoPostBack with CheckBox control in ASP.Net with C#

AutoPostBack with CheckBox control in ASP.Net with C#

STEP 2 – write the below code at aspx.cs page:

    protected void Page_Load(object sender, EventArgs e)
{
if (CheckBox1.Checked == true)
{
lblanswer.Text = “Checkbox is Checked”;
}
else
{
lblanswer.Text = “Checkbox is Un-Checked”;
}
}

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox1.Checked == true)
{
lblanswer.Text = “Checkbox is Checked”;
}
else
{
lblanswer.Text = “Checkbox is Un-Checked”;
}
}

The ASP.Net Checkbox AutoPostBack Example output is :

AutoPostBack with CheckBox control in ASP.Net with C#

AutoPostBack with CheckBox control in ASP.Net with C#

I hope this ASP.Net Example of CheckBox control AutoPostBack Property will help you……..

Leave a Reply

Your email address will not be published. Required fields are marked *

6 + 9 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">