Go to DotNetFunda.com
 Online : 870 |  Welcome, Guest!   Login
 
<<= Please see left side tutorials menu.

  • Download the OOPS, ASP.NET and ADO.NET Training Videos for FREE, click here.


Silverlight Tutorials | Report a Bug in the Tutorial

Interesting?   Share and Bookmark this

asp:CheckBox control
CheckBox control is used to give option to the user.
 
Ideally CheckBox control is used to give option to the user. When it is rendered on the page, it is implemented through <input type=checkbox></input> HTML tag. Its properties like BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height etc. are implemented through style properites of <input>. You can set its Text property either by setting Text properties in the .aspx page or from server side page. (other properties can also be set from both pages)

 

Following are some important properties that are very useful.
AutoPostBack Form is automatically posted back when CheckBox is checked or Unchecked.
CausesValidation true/false. If true, Form is validated if Validation control has been used in the form.
Checked true/false. If true, Check box is checked by default.
OnCheckedChanged Fires when CheckBox is checked or Unchecked. This works only if AutoPostBack property is set to true.
ValidationGroup Used to put a checkbox under a particular validation group. It is used when you have many set of form controls and by clicking a paricular button you want to validate a particular set of controls only.
DEMO : CheckBox Show Source Code
 
Ex. Example of Label Control
                        // CheckBox control
                        <asp:CheckBox ID="checkbox2" runat="Server" Text="Click, if Office address is same as Home address" AutoPostBack="True" OnCheckedChanged="PutHomeAddressAsOfficeAddress" BorderColor="brown" BorderWidth="1" CausesValidation="True" />
                        
                        // Fires when CheckBox is clicked(checked) or unchecked
                        protected void PutHomeAddressAsOfficeAddress(object sender, EventArgs e)
                        {
                            if (checkbox1.Checked)
                            {
                                TextBox2.Text = TextBox1.Text;
                                Label1.Text = "Notice: Home address has been written into Office TextBox too.";
                            }
                            else
                            {
                                TextBox2.Text = "";
                                Label1.Text = "Notice: Office address is empty now.";
                            }
                        }
    
                    




About Us | The Team | Advertise | Contact Us | Feedback | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found copied contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
All rights reserved to DotNetFunda.Com. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks.
(Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher)