Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Dynamic TextBox and AutoCompleteExtender

$
0
0

Hello all i am trying to create textboxes dynamically (in code behind) and simultaneous adding Ajax AutoCompleteExtender to each textbox after the texboxes have been created

the code is as follows:

protected void Button1_Click(object sender, EventArgs e)
    {
        i = Convert.ToInt32(txtNumberWorked.Text);

        for (int j = 1; j <= i; j++)
        {

            TextBox box = new TextBox();
            box.ID = "textbox" + j.ToString();

            trow = new TableRow();
            tcell1 = new TableCell();
            tcell1.Controls.Add(box);
            trow.Cells.Add(tcell1);
            mytbl.Controls.Add(trow);

                
            AjaxControlToolkit.AutoCompleteExtender kit = new AjaxControlToolkit.AutoCompleteExtender();
            kit.ID = "AutoCompleteExtender" + j.ToString();
            kit.Enabled = true;
            kit.TargetControlID = box.ID;
            kit.CompletionListCssClass = "completionList";
            kit.CompletionListHighlightedItemCssClass = "itemHighlighted";
            kit.CompletionListItemCssClass = "listItem";
            kit.CompletionInterval = 10;
            kit.MinimumPrefixLength = 1;
            kit.ServiceMethod = "GetName";
            this.Form.Controls.Add(kit);
        }


    }

The problem is after the textbox is created the code for the AutoCompleteExtender TargetControlID cannot find the textbox that has just been created.

Can anyone Hep me please and thank you


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>