Reputation: 279
Theses are the controls that im using in asp.net. Everything is inside an UpdatePanel.
<asp:TextBox ID="TxtDoc" runat="server" MaxLength="4"></asp:TextBox>
<asp:DropDownList ID="TipoDoc" runat="server" AutoPostBack="False"></asp:DropDownList>
<asp:DropDownList ID="Ddl2" runat="server" AutoPostBack="True"></asp:DropDownList>
Codebehind:
TipoDoc.Attributes.Add("onChange", "cambiarLength(this, '" + TxtDoc.ClientID + "');");
When I select an item from the dropdownlist "TipoDoc" the function cambiarLength changes the maxlength of the textbox "TxtDoc". When I select an item from the second dropdownlist "Ddl2" since the autopostback is true, the maxlength from the previous textbox is reverted to the initial value. How can I avoid such a problem like that?
Upvotes: 0
Views: 180
Reputation: 5077
Try this:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TipoDoc.Attributes.Add("onChange", "cambiarLength(this, '" + TxtDoc.ClientID + "');");
}
}
Upvotes: 0