Hi,
I'm trying to add AutoComplete behavior to a dynamically created TextBox that's in a custom server control. At first, I used the following code which worked fine:
string js = "<script type=\"text/xml-script\">" +
"<page xmlns:script=\"http://schemas.microsoft.com/xml-script/2005\">" +
"<components>" +
"<textBox id=\"" + TextBox1.ClientID + "\">" +
"<behaviors>" +
"<autoComplete completionList=\"" + completionList.ClientID + "\"" +
" serviceURL=\"WebService.asmx\"" +
" serviceMethod=\"" + webserviceMethod + "\"" +
" minimumPrefixLength=\"2\"" +
" completionSetCount=\"15\"" +
" completionInterval=\"500\" />" +
"</behaviors>" +
"</textBox>" +
"</components>" +
"</page>" +
"</script>";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "AutoComplete_" + TextBox1.ClientID, js);
But then, the control got nested into an UpdatePanel, and the autocomplete behavior was gone. Hence, I tried to add the AutoCompleteExtender by adding it as a LiteralControl like this:
Panel panTextBox = new Panel();
panTextBox.Controls.Add(new LiteralControl("<atlas:AutoCompleteExtender ID=\"" + "AutoComplete_" + TextBox1.ClientID + "\" ServicePath=\"~/WebService.asmx\" ServiceMethod=\"" + webserviceMethod + "\" MinimumPrefixLength=\"2\" runat=\"server\">" + "<atlas:AutoCompleteProperties TargetControlID=\"" + TextBox1.ClientID + "\" Enabled=\"true\" />" +"</atlas:AutoCompleteExtender>") );
this
.Controls.Add(panTextBox); //this = custom server control
That doesn't work, even though I removed the UpdatePanel. Can anybody help me adding auto complete behavior to the TextBox control?