This is a migrated thread and some comments may be shown as answers.

[Solved] AutoCompleteExtender

1 Answer 178 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David Fox
Top achievements
Rank 1
David Fox asked on 16 Oct 2009, 03:26 PM

I'm not sure if this has something to do with page life cycle, but the Autocompleteextender control doesn't behave as expected. Firebug tells me the control is rendered as follows at runtime:

<em unselectable="on">The TargetControlID of 'AutoCompleteExtender1' is not valid. A control with ID 'UserControl1_TextBox1' could not be found.</em>

I guess the control can't be found because it doesn't exist yet??

How can I make this work? Due to layout, I can't move TextBox1 into ParentPage.aspx

UserControl1.ascx:

  1. TextBox1 (I'd like to make the target of a Toolkit AutoCompleteExtender)
    1. rendered as UserControl1_TextBox1
    2. <asp:TextBox ID="TextBox1" runat="server" class="allcaps"></asp:TextBox>

UserControl1.ascx.cs:

  1. Page_Load method (before the check for postback)
    1. AutoCompleteExtender ace = (AutoCompleteExtender)this.Parent.FindControl("AutoCompleteExtender1");
      ace.TargetControlID = TextBox1.UniqueID;

ParentPage.aspx (RadWindow):

  1. Form1
    1. RadScriptManager1
    2. UserControl1
    3. RadAjaxManager1

ParentPage.aspx.cs

  1. Page_Load method
    1. AutoCompleteExtender AutoCompleteExtender1 = new AutoCompleteExtender();
      AutoCompleteExtender1.ID = "AutoCompleteExtender1";
                  
      AutoCompleteExtender1.ServicePath = "AutoCompleteUserControl.asmx";
      AutoCompleteExtender1.ServiceMethod = "GetVendorData";
      AutoCompleteExtender1.MinimumPrefixLength = 1;
      AutoCompleteExtender1.CompletionSetCount = 12;
      
      HtmlForm form = this.Page.FindControl("Form1") as HtmlForm;
      form.Controls.Add(AutoCompleteExtender1);

AutoCompleteUserControl.asmx.cs has a WebMethod:

public string[] GetVendorData(string prefixText, int count)

1 Answer, 1 is accepted

Sort by
0
David Fox
Top achievements
Rank 1
answered on 16 Oct 2009, 05:53 PM
click here for sample project
Tags
General Discussions
Asked by
David Fox
Top achievements
Rank 1
Answers by
David Fox
Top achievements
Rank 1
Share this question
or