On checkbox changed event (C#) : CheckBox « Asp Control « ASP.Net






On checkbox changed event (C#)

<%@Page Language="C#" %>
<html>
<head>
<title>Web Form 'Change' and 'Click' Events</title>
</head>
<body>
<span class="heading">Web Form 'Change' and 'Click' Events</span><p />

<form runat="server">

<asp:textbox id="MyText" text="OriginalValue"
     ontextchanged="MyChangeCode" runat="server" /> &nbsp;

<asp:dropdownlist id="MyListBox"
     onselectedindexchanged="MyChangeCode" runat="server">
  <asp:listitem text="Option 1" value="Value1" runat="server" />
  <asp:listitem text="Option 2" value="Value2" runat="server" />
  <asp:listitem text="Option 3" value="Value3" runat="server" />
</asp:dropdownlist> &nbsp;

<asp:checkbox id="MyCheckBox"
     oncheckedchanged="MyChangeCode" runat="server" /> &nbsp;

<asp:button id="MySubmitButton" text="Submit"
     onclick="MyClickCode" runat="server" /> &nbsp;

</form>

<div id="divResult" runat="server" enableviewstate="false" /><p />
<div class="cite">Change the values in the controls and click 'Submit'</div>

<script runat="server">

void MyChangeCode(object objSender, EventArgs objArgs) {
  Control ctrSender = (Control)objSender;
  divResult.InnerHtml += "Change event detected for control '"
                      + ctrSender.ID + "'<br />";
}

void MyClickCode(object objSender, EventArgs objArgs) {
  Control ctrSender = (Control)objSender;
  divResult.InnerHtml += "Click event detected for control '"
                      + ctrSender.ID + "'<br />";
}

</script>
</body>
</html>

           
       








Related examples in the same category

1.asp:CheckBox: change font and border (VB.net)
2.On asp:CheckBox selection state changed (VB.net)
3.asp:CheckBox: text align (VB.net)
4.Set asp:checkbox checked (VB.net)
5.Set Text, TextAlign and Font name for a asp:CheckBox (VB.net)
6.Watch TextBox, CheckBox and radiobutton auto post back action (C#)
7.Get Check box selection state (C#)
8.Set Text, TextAlign and Font name for a asp:CheckBox (C#)
9.Define function to change Label Font to Italic (C#)
10.CheckBox AutoPostBack (VB.net)