c# - dropdown initializing input type="text" on postback -
i have several text boxes <input type="text">
a dropdownlist<asp:dropdownlist>
prefer use asp control want bind data. thing every time make selection text boxes re-initializes due post back.
<asp:dropdownlist id="drppleaseselect" runat="server" onselectedindexchanged="drppleaseselect_selectedindexchanged" autopostback="true" > <asp:listitem>[please select yes or no]</asp:listitem> <asp:listitem>yes</asp:listitem> <asp:listitem>no</asp:listitem> </asp:dropdownlist> <input type="text" runat="server" id="txtlastname" onkeyup="checktextboxes()" onfocus="checktextboxes()" /> protected void drppleaseselect_selectedindexchanged(object sender, eventargs e) { var valuedropdown = drppleaseselect.selectedvalue.tostring(); if (valuedropdown == "[please select yes or no]") { labchkdropdown.innerhtml = "please select yes or no"; } else if (valuedropdown == "yes" || valuedropdown == "no") { //bind different asp:dropdownlist database data } }
is there way html text boxes not affected postback make changes index of dropdown list?
you said every time make selection text boxes re-initialize, setting them on pageload or function called pageload?
if case think missing check ispostback:
protected void page_load(object sender, eventargs e) { if (!ispostback) { //do stuff want done on inital page load. //like setting inital values in textboxes, etc. } }
Comments
Post a Comment