c# - set the visibility of text box to false when the rad combo box shows empty message string -
i have user control in using 1 editable rad combo , 1 rad text box. depends on value of combo need set visibility of text box. working. code follows.
1. user control
<asp:panel id="pnl44" runat="server" visible="false"> <table width="100%"> <tr> <td style="width: 20%;"> quantity<span style='color: red'>* </span> </td> <td align="left" style="vertical-align: top; width: 80%;"> <table width="100%"> <tr> <td align="left" style="vertical-align: top; width: 63%;"> <telerik:radcombobox id="pnl44_ddlunit" runat="server" dropdownautowidth="enabled" width="150px" autopostback="true" onselectedindexchanged="ddlunit_selectedindexchanged" emptymessage="---select---" markfirstmatch="true" allowcustomtext="false" onclientblur="onclientblurhandler"></telerik:radcombobox> </td> <td> <asp:textbox id="pnl44_txtquantity" maxlength="10" runat="server" cssclass="textfield" width="145px" /> <ajaxtoolkit:filteredtextboxextender id="ftetxtquantity" filtertype="numbers" runat="server" targetcontrolid="pnl44_txtquantity" /> </td> </tr> </table> </td> </tr> </table> </asp:panel>
in code behind handling selected changed event set visibility, working fine. javascript on blur follows (it in aspx page).
<script type="text/javascript" language="javascript"> function onclientblurhandler(sender) { var item = sender.finditembytext(sender.get_text()); if (!item) { sender.clearselection(); } } </script>
with whenever combo value null, show empty message.
the scenario this
by default visibility of txtquantity false. when user select 'value1' combo, txtquantity visibility true; user deleting value1 using delete/backspace, combo box show empty message string, time txtquantity visibility true, instead false.
please me solve issue...
it seems change textbox visibility on server, need initiate request when clear combo selection. basics:
function onclientblurhandler(sender) { var item = sender.finditembytext(sender.get_text()); if (!item) { sender.clearselection(); __dopostback("", ""); } }
which generate generic postback. can use hidden buttons or hidden fields or other arguments know postback originated from.
option 2: hide textbox javascript, e.g.:
function onclientblurhandler(sender) { var item = sender.finditembytext(sender.get_text()); if (!item) { sender.clearselection(); document.getelementbyid("<%=pnl44_txtquantity.clientid%>").style.display="none"; } }
or similar, depending on act control textbox.
Comments
Post a Comment