Multipe Dynamic Controls & AutoPostback Issue

Posted on 16th Feb 2014 by admin

I currently have a need to create many dynamic controls (Example Textboxes) that need to do a PostBack upon the data in the control changing (Autopostback = true). The following sample code demononstrates the example. When the code is executed, I can click on a control, enter in some text, and then hit the tab key (not concerned about the focus issue here), If I then click on another control enter in some text again and hit tab again, (postback issued again). It now at this point jumps to the next control, and seems to be non functional. No text can be entered. I click on another control, that control gains focus, but still can not enter in any text. I can't figure out what is going on. view plaincopy to clipboardprint?public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { for (int x = 0; x < 30; x++) { TextBox Test = null; Test = new TextBox(); Test.ID = x.ToString(); Test.AutoPostBack = true; MyHolder.Controls.Add(Test); } } } public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { for (int x = 0; x < 30; x++) { TextBox Test = null; Test = new TextBox(); Test.ID = x.ToString(); Test.AutoPostBack = true; MyHolder.Controls.Add(Test); } } }
view plaincopy to clipboardprint?<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestAjax._Default" %> Untitled Page

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestAjax._Default" %> Untitled Page

Any Help would be GREATLY APPRECIATED - Driving me nuts!

Other forums