c# - A controls disabled through server side is still enabled in client side why? -
i have .net control. disabling list items of controls using attribute property. in client side validation checking whether control enabled or disabled. j query written still says controls enabled if disabled , fires alert. kind of struggling can me please..
here code
private void enabledisablecontrol(listcontrol control, boolean value) { if (value == true) { foreach (listitem item in control.items) { item.attributes.remove("checked"); item.attributes.add("disabled", "disabled"); } } else { foreach (listitem item in control.items) { item.attributes.remove("disabled"); } } }
i used function disabled 1 of control
enabledisablecontrol(rdb_control, true);
here jquery
if ($("#<%=rdb_control.clientid%> input[type='radio']").is(':enabled')) { if ($("#<%=rdb_control.clientid%> input[type='radio']:checked").length == 0) { alert("required"); } }
here control disabled still alert. whereas shouldn't check if control disabled.
here html looks disables span
<table id="ctl00_m_g_c09fd465_0ae4_479b_8fc6_21a7de645003_ctl00_rdb_control" class="chklistunknown" border="0"> <tr> <td><span disabled="disabled"><input id="ctl00_m_g_c09fd465_0ae4_479b_8fc6_21a7de645003_ctl00_rdb_control_0" type="radio" name="ctl00$m$g_c09fd465_0ae4_479b_8fc6_21a7de645003$ctl00$rdb_control" value="yes" /><label for="ctl00_m_g_c09fd465_0ae4_479b_8fc6_21a7de645003_ctl00_rdb_control_0">is</label></span></td> </tr><tr> <td><span disabled="disabled"><input id="ctl00_m_g_c09fd465_0ae4_479b_8fc6_21a7de645003_ctl00_rdb_control_1" type="radio" name="ctl00$m$g_c09fd465_0ae4_479b_8fc6_21a7de645003$ctl00$rdb_control" value="no" /><label for="ctl00_m_g_c09fd465_0ae4_479b_8fc6_21a7de645003_ctl00_rdb_control_1">not</label></span></td> </tr><tr> <td><span disabled="disabled"><input id="ctl00_m_g_c09fd465_0ae4_479b_8fc6_21a7de645003_ctl00_rdb_control_2" type="radio" name="ctl00$m$g_c09fd465_0ae4_479b_8fc6_21a7de645003$ctl00$rdb_control" value="unknown,yes" /><label for="ctl00_m_g_c09fd465_0ae4_479b_8fc6_21a7de645003_ctl00_rdb_control_2">unknown</label></span></td> </tr> </table>
well, problem in server-side code. disabling span
elements, cannot disabled. when jquery asks whether radiobuttons
enabled, answer yes... because enabled. no radiobutton has disabled
attribute.
you've got change server method , dig further in control tree find , disable inputs
, not spans
.
the checklistcontrol
has enabled
property. set false
:
private void enabledisablecontrol(listcontrol control, boolean value) { control.enabled = value; }
it should disable checkboxes automatically.
Comments
Post a Comment