You can do that nicely with a little Javascript which you output from your
codebehind. I've create a demo sample below that might get you started.
Let us know if this helps?
Ken
Microsoft MVP [ASP.NET]
Toronto
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim sb As New System.Text.StringBuilder
sb.Append("<script>")
sb.Append("function AddChks()")
sb.Append("{")
sb.Append("var intChkTotal=0;")
sb.Append("if (document.forms[0].CheckBox1.checked==true)")
sb.Append("{")
sb.Append("intChkTotal = intChkTotal + 1")
sb.Append("}")
sb.Append("if (document.forms[0].CheckBox2.checked==true)")
sb.Append("{")
sb.Append(" intChkTotal = intChkTotal + 1")
sb.Append("}")
sb.Append("if (document.forms[0].CheckBox3.checked==true)")
sb.Append("{")
sb.Append(" intChkTotal = intChkTotal + 1")
sb.Append("}")
sb.Append("document.forms[0].TextBox1.value=intChkTotal;")
sb.Append("}")
sb.Append("</script>")
Page.RegisterClientScriptBlock("myscript", sb.ToString)
CheckBox1.Attributes.Add("onclick", "AddChks()")
CheckBox2.Attributes.Add("onclick", "AddChks()")
CheckBox3.Attributes.Add("onclick", "AddChks()")
End Sub
Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Label1.Text = TextBox1.Text
End Sub
<form id="Form1" method="post" runat="server">
<p>
<asp:checkbox id="CheckBox1"
runat="server"></asp:checkbox></p>
<p>
<asp:checkbox id="CheckBox2"
runat="server"></asp:checkbox></p>
<p>
<asp:checkbox id="CheckBox3"
runat="server"></asp:checkbox></p>
<p>
<asp:textbox id="TextBox1" runat="server"></asp:textbox></p>
<p>
<asp:button id="Button1" runat="server"
Text="Button"></asp:button></p>
<p>
<asp:label id="Label1" runat="server">Label</asp:label></p>
</form>