Dynamic checkbox checked event in asp.net


Description:-

In this article we will see How to Handle Dynamic Checkbox Checked Event in dot net. Here I have Create Simple demo to Understand Easily. For Create Dynamic Check box you have to Create Checkbox Dynamically in Page_Load event. Here I have Created Check box and Handle that Created Checkbox Event for Check or Uncheck.

You can create much control Dynamically in dot net. Here I have used Checkbox Control to Understand.

Create Webpage and Add Label control for Display Messgae . when we checkd or uncheck from that Check box Control.

Default.aspx:-

<div>
  <asp:Label ID="lblMessage" runat="server" Text="Label"></asp:Label>
</div>

Default.aspx.cs:-

protected void Page_Load(object sender, EventArgs e)
        {
            chkDynamic = new CheckBox();
            chkDynamic.ID = "chkExample";
            chkDynamic.Text = "Check / Uncheck";
            chkDynamic.AutoPostBack = true;
            chkDynamic.CheckedChanged += new EventHandler
                               (chkDynamic_CheckedChanged);
            this.Form.Controls.Add(chkDynamic);
        }

Her is the Checkbox Checked Event perform action on that check Box.

protected void chkDynamic_CheckedChanged (object sender, EventArgs e)
        {
            if (chkDynamic.Checked)
                lblMessage.Text = "you checked the checkbox";
            else if (!chkDynamic.Checked)
                lblMessage.Text = "checkbox is not checked";
        }

Now we are done to perform Checkbox Event. Run your application there you will get Checkbox control for Check or Uncheck.

Related Posts

Thanks for comments.....

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer