I wonder if someone can point out where I'm going wrong with this code.
My aim is to control the visibility of an UpdatePanel with a CheckBox. The CheckBox is located on the same form, but not adjacent to the UpdatePanel. ScriptManager is present, but when browsing, checking the CheckBox doesn't make the panel visible. See below snippets, the current method used is AutoPostBack, but I'm sure this isn't the most effective way of updating the panel.
Here is the CheckBox code:
<!-- more options checkboxes -->
<asp:CheckBox ID="HousekeepingCheckBox" runat="server" AutoPostBack="true" /> Housekeeping<br />
Here is the UpdatePanel:
<asp:UpdatePanel ID="HousekeepingUpdatePanel" runat="server" Visible="False" UpdateMode="Conditional">
<ContentTemplate>
<p>
Housekeeping Requirements:
</p>
<p>
<asp:CheckBox ID="HKHandTowelsCheckBox" runat="server" Text="Hand towels and toilet paper are restocked before the event begins" /><br />
<asp:CheckBox ID="HkWasteBinsCheckBox" runat="server" Text="There are adequate waste bins for the disposal of hand towels" /><br />
<asp:CheckBox ID="HKRoomsCleanedAfterCheckBox" runat="server" Text="The rooms used are cleaned after the event" /><br />
</ContentTemplate>
</asp:UpdatePanel>
The code behind currently used to enable the UpdatePanel is:
Protected Sub HousekeepingCheckBox_CheckedChanged(sender As Object, e As EventArgs) Handles HousekeepingCheckBox.CheckedChanged
If HousekeepingCheckBox.Checked = True Then
HousekeepingUpdatePanel.Visible = True
Else
HousekeepingUpdatePanel.Visible = False
End If
End Sub
I've looked at Triggers but not sure this is the solution and I haven't had any joy without AutoPostBack.
Can anyone please advise on the correct way?
Many thanks