asp.net - Setting MaxLength on TextBox depending upon DropDownList selection? -
i have textbox displayed depending upon selection in dropdownlist. default behavior of textbox visible="false"
. maxlength value need vary depending upon selection in dropdownlist. note textbox not displayed.
i have provided markup below.
<asp:updatepanel id="updatepanel" runat="server" childrenastriggers="false" updatemode="conditional" rendermode="inline"> <contenttemplate> <asp:dropdownlist id="ddllist" runat="server" autopostback="true" onselectedindexchanged="ddllist_selectedindexchanged"> </asp:dropdownlist> <asp:textbox id="tbother" runat="server" visible="false" onprerender="tbother_prerender"></asp:textbox> </contenttemplate> <triggers> <asp:asyncpostbacktrigger controlid="ddllist" /> </triggers> </asp:updatepanel>
i'm still working through way address issue, possible save value maxlength on dropdownlist , then, in code behind, use value set maxlength on textbox? since have dropdown in updatepanel , using autopostback seems should possible don't know how/where value stored.
yep. can this.
void page_load() { tbother.maxlength = int32.parse(ddllist.selectedvalue); }
the value automatically stored in page's viewstate don't have worry @ all.
Comments
Post a Comment