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

Dynamic AutoCompleteExtender not work with dynamic TextBox

$
0
0

This question was an old one as I went through the search results but still stuck at the latest version of ASP.NET(4.5) and AjaxToolKit(15.1.3.0) I'm afraid.  I have a need to dynamically create TextBoxes in a ListView ItemTemplate as repeated controls with attached AutoCompleteExtenders, so I need to make sure the ACE can work with each TextBox created. I had experimented the collaboration of TextBox and ACE declaratively and also created a WebService to query the database, and they worked fine, so next I tried to adapt the markups into server code:

        int aField = 322;
        TextBox tbCellContent = new TextBox();
        tbCellContent.ID = "tbCellContent_" + aFieldID;
        //tbCellContent.Attributes.Add("autocomplete", "off");    
        AutoCompleteExtender ace = new AutoCompleteExtender();
        ace.ID = "tbCellContent_AutoCompleteExtender_" + aFieldID;
        ace.BehaviorID = "tbCellContent_AutoCompleteExtender_" + aFieldID;
        ace.TargetControlID = tbCellContent.ID;
        ace.ServiceMethod = "SearchFIData";
        ace.CompletionInterval = 500;
        ace.CompletionSetCount = 10;
        ace.OnClientItemSelected = "IAmSelected";
        ace.MinimumPrefixLength = 1;
        ace.ServicePath = "~/WebService.asmx";
        ace.UseContextKey = true;
        ace.Enabled = true;
        ace.EnableCaching = true;
        ace.ContextKey = aFieldID.ToString();

        Panel1.Controls.Add(tbCellContent);  //Panel1 is inside an UpdatePanel
        Panel1.Controls.Add(ace);

However, this code failed to work. When typing in the Textbox the ServiceMethod in WebServices.asmx is not entered as how it reacted with the static markups. Anyone could tell if I have any steps or statements missing to make it work? Many thanks in advance. Also can we make multiple programaticaly created TextBoxes share one common ACE? (Of course we have to make ONE successfully work first)

p.s., The closest solution I found was this one http://forums.asp.net/p/1002885/1324816.aspx , however the thread was created almost a decade ago and the mentioned method seems already obsolete. (such as thatAutoCompleteProperties)


Viewing all articles
Browse latest Browse all 5678

Trending Articles



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