all groups > dotnet academic > may 2004 >
You're in the

dotnet academic

group:

checking/unchecking while enabling/disabling checkboxes


checking/unchecking while enabling/disabling checkboxes Gail G via .NET 247
5/14/2004 11:19:03 AM
dotnet academic:
I am updating a page which has a table with four checkboxes that receives data from a db. The results are sent to a database, but

only two of the four checkbox values are stored into two fields in the db.

Critical
The user can not select more than two of the four checkboxes at any given time; the remaing 2 checkboxes must always be

disabled.

Currently
When the page loads the appropriate 2 of the 4 checkboxes are checked and the remaining 2 are unchecked and enabled.

Goal:
(1) When the page loads how do I disabled the 2 unchecked checkboxes.
(2) When the user unchecks 1 of the 2 currently checked checkboxes--enable the other 2 checkboxes which were previously
disabled.
(3) Only 2 of the 4 checkboxes are checked at any given time and the remaining 2 must be disabled.

My code snipet------>When the page loads, my aspx.vb is:

If DSPageData.Tables("ViewSelected").Rows(0).Item("TypeCode1") = "Q" Or
DSPageData.Tables("ViewSelected").Rows(0).Item("TypeCode2") = "Q" Then
chkQuality.Checked = True
End If

If DSPageData.Tables("ViewSelected").Rows(0).Item("TypeCode1") = "F" Or
DSPageData.Tables("ViewSelected").Rows(0).Item("TypeCode2") = "F" Then
chkFinancial.Checked = True
End If

If DSPageData.Tables("ViewSelected").Rows(0).Item("TypeCode1") = "C" Or
DSPageData.Tables("ViewSelected").Rows(0).Item("TypeCode2") = "C" Then
chkCustomer.Checked = True
End If

If DSPageData.Tables("ViewSelected").Rows(0).Item("TypeCode1") = "E" Or
DSPageData.Tables("ViewSelected").Rows(0).Item("TypeCode2") = "E" Then
chkEmployee.Checked = True
End If

My .aspx looks like:
<htm>
<head><title>Checkbox and More</title></Head>
<body>
<form>
<table>
<asp:checkbox id="chkQuality" runat="server" Text="Quality" AutoPostBack="True"></asp:checkbox>
<asp:checkbox id="chkFinancial" runat="server" Text="Financial" AutoPostBack="True"></asp:checkbox>

<asp:checkbox id="chkCustomer" runat="server" Text="Customer Service" AutoPostBack="True"></asp:checkbox>
<asp:checkbox id="chkEmployee" runat="server" Text="Employee" AutoPostBack="True"></asp:checkbox>
<asp:button id="btnUpdate" runat="server" Font-Names="Arial" Text="Save"></asp:button>
</table>
</form>
</body>
</html>


--------------------------------
From: Gail G

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

Re: checking/unchecking while enabling/disabling checkboxes Eric Marvets
5/21/2004 9:47:09 PM
For the checkboxes, set their AutoPostBack property to True. Then, capture
the events on the server and set the checkboxes Enabled property to True or
False.

--
Eric Marvets
Principal Consultant

the bang project

<shameless self promotion>

Email sales@bangproject.com for Information on Our Architecture and
Mentoring Services

</shameless self promotion>

[quoted text, click to view]

AddThis Social Bookmark Button