Hi,
We have a base page where we need to traverse through all controls on the current page instance and set them to ReadOnly mode.
This works fine for most of the controls but does not work for RadComboBox. Process never gets into if (cntrl is RadComboBox) clause. Here is the function:
We have a base page where we need to traverse through all controls on the current page instance and set them to ReadOnly mode.
This works fine for most of the controls but does not work for RadComboBox. Process never gets into if (cntrl is RadComboBox) clause. Here is the function:
private void SetControlReadOnly(Control cntrl) |
{ |
if (cntrl.HasControls()) |
{ |
foreach (Control nestedContrl in cntrl.Controls) |
{ |
SetControlReadOnly(nestedContrl); |
} |
} |
else |
{ |
if (cntrl is RadComboBox) |
{ |
RadComboBox ddl = (RadComboBox)cntrl; |
ddl.Enabled = false; |
} |
else if (cntrl is RadInputControl) |
{ |
SetRadInputControlReadOnly((RadInputControl)cntrl); |
} |
else if (cntrl is CheckBox) |
{ |
CheckBox chk = ((CheckBox)cntrl); |
chk.Enabled = false; |
} |
else if (cntrl is TextBox) |
{ |
TextBox txt = ((TextBox)cntrl); |
txt.Enabled = true; |
txt.ReadOnly = true; |
txt.ForeColor = System.Drawing.Color.Black; |
} |
} |
} |
private void SetRadInputControlReadOnly(RadInputControl input) |
{ |
input.Enabled = true; |
input.ReadOnly = true; |
//input.BorderStyle = BorderStyle.None; |
input.DisabledStyle.ForeColor = System.Drawing.Color.Black; |
} |