user1292267
user1292267

Reputation: 31

Autopostback textbox not retaining the values across postbacks with nested form tags

Here the textbox with id as "a" retains the value after postbacks while textbox with id as "b" not retains the value.Why this happens?

<form id="form1" runat="server">
        <div>
         <asp:TextBox ID="a" runat="server"  AutoPostBack="true" ></asp:TextBox>
            <form action="javascript:myFunc();">
            <p>
                <input type="text" id="city-field" name="city" " />
                <input type="submit" value="Find" /></p>
            </form>
        </div>
           <asp:TextBox ID="b" runat="server"  AutoPostBack="true" ></asp:TextBox>
        </form>

Upvotes: 0

Views: 478

Answers (1)

SLaks
SLaks

Reputation: 887837

HTML does not support nested <form> tags.

The browser drops the inner <form>, then uses the inner </form> to close the outer <form>.
Therefore, the second textbox never gets posted back.

You can see this in Firebug.

Upvotes: 3

Related Questions