0

So, I have a gridview containing textboxes wrapped in autocomplete extenders.

A button outside of the gridview is clicked to clear and set focus to a specific textbox in the gridview.

When the textbox is entered and I key in data the autocomplete options don't pop up. (The auto-complete does work prior to the button click event below)

Below is the code on the button click event

GridViewRow r = gvdView.Rows[0];
TextBox txtbox = (TextBox)r.FindControl("txtG");

if (txtbox != null)
{
    txtbox.Text = string.Empty;
    txtbox.Focus();

    //I added this in, but it doesn't seem to work
    AjaxControlToolkit.AutoCompleteExtender kit = new AjaxControlToolkit.AutoCompleteExtender();
    kit.ID = "AutoCompleteExtenderZ";
    kit.TargetControlID = txtbox.UniqueID;
    kit.Enabled = true;
    kit.CompletionListCssClass = "autoExtender";
    kit.CompletionInterval = 10;
    kit.MinimumPrefixLength = 1;
    kit.ServiceMethod = "GetSearchedList";
    Form.Controls.Add(kit);
}
Keegan
  • 23
  • 4
  • Have you defined the `GetSearchedList` method otherwise you must provide a `ServicePath`. You can check this [Link](http://www.ajaxtoolkit.net/AutoComplete/AutoComplete.aspx) for more information. – Jawad Anwar Feb 01 '19 at 13:35
  • I have found out the hard way that the one extender you are using just doesn't want to work when you automatically set focus on it. I had this problem with my modal dialog, whenever i would open it it would focus on the first textbox which was my autocomplete and it would stop working unless I focus another textbox and then back by hand. Is it mandatory for you to set the focus? – a.bajorinas Feb 01 '19 at 15:25
  • Hi, My GetSearchedList method is defined and works right up until I set focus to the textbox. – Keegan Feb 03 '19 at 06:39
  • When someone clicks a textbox isn't that textbox then in a state of "hasfocus()"? The autocomplete works then, so I feel like I'm missing a few defining lines of code from manually doing it, versus in the code-behind. – Keegan Feb 03 '19 at 06:43

0 Answers0