RadComboBox enable disable from codebehind

2 Answers 47 Views
ComboBox
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Fit2Page asked on 23 Oct 2023, 11:18 AM

The following code disables the combobox, but I cannot enable it by unchecking the checkbox again...howcome?

 

   <telerik:RadComboBox Width="100%"  ID="rcb_zorgverzekeraar" runat="server"></telerik:RadComboBox>
                                           
                  <asp:CheckBox ID="chk_verzekeraar" CausesValidation="false" AutoPostBack="true" OnCheckedChanged="chk_verzekeraar_CheckedChanged" Text="Ik weet het niet" runat="server" />

 

 

with:

 

        Protected Sub chk_verzekeraar_CheckedChanged(sender As Object, e As EventArgs)
            rcb_zorgverzekeraar.Enabled = Not chk_verzekeraar.Checked
        End Sub

 

 

Marc

2 Answers, 1 is accepted

Sort by
0
Vasko
Telerik team
answered on 24 Oct 2023, 03:18 PM

Hello Marc,

I tested the provided code and on my end, everything worked as intended - the checkbox was able to disable/enable the ComboBox. I'd advise you to check if somehow you disable the ComboBox in any of the page lifecycle events.

This may not be the solution, but could you try the following way to toggle the disabled state and let me know the outcome:

Protected Sub chk_verzekeraar_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
    Dim checkBox = TryCast(sender, CheckBox) 

    If checkBox.ID = "chk_verzekeraar" AndAlso checkBox.Checked Then
        rcb_zorgverzekeraar.Enabled = False
    Else
        rcb_zorgverzekeraar.Enabled = True
    End If
End Sub

Kind regards,
Vasko
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
0
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
answered on 25 Oct 2023, 08:33 AM

Hi Vasko,

 

An EnableViewState="false" on the masterpage was the devil.

 

Thank for your time.

 

Marc

Tags
ComboBox
Asked by
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Vasko
Telerik team
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or