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:
- TextBox1 (I'd like to make the target of a Toolkit AutoCompleteExtender)
- rendered as UserControl1_TextBox1
-
<asp:TextBox ID="TextBox1" runat="server" class="allcaps"></asp:TextBox>
UserControl1.ascx.cs:
- Page_Load method (before the check for postback)
-
AutoCompleteExtender ace = (AutoCompleteExtender)this.Parent.FindControl("AutoCompleteExtender1"); ace.TargetControlID = TextBox1.UniqueID;
-
ParentPage.aspx (RadWindow):
- Form1
- RadScriptManager1
- UserControl1
- RadAjaxManager1
ParentPage.aspx.cs
- Page_Load method
-
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)