Hi @Coreysan ,
I tried your said but I didn't reproduce your problem. Tab key is just the client operation to jump to the next control. After you tab to the fixed textbox,you need to change the textbox's value,and then it will fire the textchanged event.
My demo codes:
<div runat="server" id="div1">
</div>
<div>
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</div>
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 1; i <=2; i++)
{
AddControls(i);
}
}
private void AddControls(int controlNumber)
{
var newPanel = new Panel();
var newLabel = new Label();
var newTextbox = new TextBox();
// textbox needs a unique id to maintain state information
newTextbox.ID = "TextBox_" + controlNumber;
newLabel.Text = "txt"+controlNumber+"000: ";
// add the label and textbox to the panel, then add the panel to the form
newPanel.Controls.Add(newLabel);
newPanel.Controls.Add(newTextbox);
newTextbox.AutoPostBack = true;
newTextbox.TextChanged += new System.EventHandler(this.txtBox_TextChanged);
div1.Controls.Add(newPanel);
}
private void txtBox_TextChanged(object sender, EventArgs e)
{
var x= (sender as TextBox).Text;
TextBox txt2 = (TextBox)form1.FindControl("TextBox_2");
txt2.Text = x;
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
Label1.Text="1";
}
Result:
Best regards,
Yijing Sun
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.