This has me totally puzzled, can anyone explain this?
Markup:
<form id="form1" runat="server">
<asp:TextBox runat="server" ID="txtTest" />
<asp:PlaceHolder runat="server" ID="PlaceHolder1" />
<asp:Button runat="server" Text="Click" />
</form>
Code Behind:
protected void Page_Load(object sender, EventArgs e)
{
txtTest.Text = "BBB";
PlaceHolder1.Controls.Add(new TextBox() { Text = "AAA" });
}
When I change the text in both textboxes, then click the 'Click' button, the text in txtTest is reverted back to the original value 'BBB'(specified in page_load), but the dynamic textbox retains the value I just entered (and not 'AAA') despite this being specified at the same time as the other, 'hardcoded' textbox.