Wednesday, 15 August 2012

asp.net - disable button until value is selected ---select---doesnt appear -



asp.net - disable button until value is selected ---select---doesnt appear -

so far working ok, button disabled until value selected drop downwards list, want ---select--- first alternative on drop downwards list, not happening...any ideas why?

<asp:dropdownlist id="dropdownlistsubcontractors" runat="server" appenddatabounditems="true" datatextfield="company_name" datavaluefield="id" onchange='selectchanged(this);'> <asp:listitem text="---select---" value="0" /> <asp:listitem text="option 1" value="1" /> </asp:dropdownlist> <script type="text/javascript"> function selectchanged(e) { document.getelementbyid("<%= addnewsubcontractor.clientid %>").disabled = (e.options[e.selectedindex].value == "0") ? "disabled" : ""; } </script> <asp:button id="addnewsubcontractor" text="add sub contractor" onclick="uploadsubcontractor" runat="server" disabled='disabled' />

showing manually added items first followed info bound items default behavior of drop downwards list, ---select--- should in theory first item.

i suspect there logic elsewhere(can javascript or code behind) sets selected item else i.e:

dropdownlistsubcontractors.selectedindex = 1;

have through code , create sure selected item not beingness re-set anywhere

asp.net drop-down-menu disabled-control javascript

No comments:

Post a Comment