AutoCompleteBox.Entries empty on AJAX postback

3 posts, 0 answers
  1. SEE Global IT Development Team
    SEE Global IT Development Team avatar
    7 posts
    Member since:
    Nov 2008

    Posted 25 Mar 2014 Link to this post

    Hello,

    I've encountered some surprising behaviour with the RadAutoCompleteBox.Entries property during the implementation of a custom DataSourceSelect event.  Unless I also implement the EntryAdded and EntryRemoved events, the items added to or removed from the box by the user do not show up in the Entries collection of the control in the DataSourceSelect event handler.

    I have an AutoCompleteBox defined as follows:
    <telerik:RadAutoCompleteBox ID="titles" runat="server" InputType="Token" TokensSettings-AllowTokenEditing="false" DataTextField="Title" DataValueField="TitleID" OnDataSourceSelect="titles_DataSourceSelect" OnEntryAdded="titles_EntryAdded" Width="400px"></telerik:RadAutoCompleteBox>

    I have a method that queries my back end database with the text entered by the user and sets the data source.  Before querying the database, I get the items that have already been added to the control and include their IDs in the database queries, so that they can be filtered out of the drop down of matches.  In other words, if a user has types in text, picked an item form the dropdown and added it to the control, I ensure that the same item does not appear again in the dropdown.

            protected void titles_DataSourceSelect(object sender, AutoCompleteBoxDataSourceSelectEventArgs e)<br>        {<br>            List<int> exclude = new List<int>();<br>            foreach (AutoCompleteBoxEntry entry in titles.Entries)<br>            {<br>                int id = -1;<br>                if (int.TryParse(entry.Value, out id))<br>                {<br>                    exclude.Add(id); <br>                }<br>            }<br><br>            titles.DataSource = Database.SearchDimension("Title", e.FilterString, exclude); // call DAL<br>        }<br>

    I have put a RadAjaxManager on the page and given the AutoCompleteBox the ability to ajaxically update itself.
             <telerik:AjaxSetting AjaxControlID="titles">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="titles" UpdatePanelRenderMode="Inline" />
                    </UpdatedControls>
                 </telerik:AjaxSetting>

    But the above doesn't work.  When my DataSourceSelect event handler fires, the Entries collection of the control is always empty.

    If I implement empty event handlers for EntryAdded and EntryRemoved, it works as expected, and the Entries collection contains the items which have been previously selected by the user.

    <telerik:RadAutoCompleteBox ID="titles" runat="server" InputType="Token" TokensSettings-AllowTokenEditing="false" DataTextField="Title" DataValueField="TitleID" OnDataSourceSelect="titles_DataSourceSelect" OnEntryAdded="titles_EntryAdded" OnEntryRemoved="titles_EntryRemoved" Width="400px"></telerik:RadAutoCompleteBox>

            protected void titles_EntryAdded(object sender, AutoCompleteEntryEventArgs e)<br>        {<br>        }<br><br>        protected void titles_EntryRemoved(object sender, AutoCompleteEntryEventArgs e)<br>        {<br>        }

    If I eliminate either one of these two event handlers, the corresponding action is not taken into account in the Entries collection.  So if I remove EntryAdded, items I add to the control are not taken into account.  If I remove EntryRemoved, when I add and then remove an item, it still shows up in the Entries collection.

    On a full page postback triggered by something else, the Entries collection always correctly lists items really entered in the web form.

    I am running this in a SharePoint 2010 custom Application page.

    This looks like a bug to me, but maybe I've misunderstood the API for this control and am not using it correctly.



  2. SEE Global IT Development Team
    SEE Global IT Development Team avatar
    7 posts
    Member since:
    Nov 2008

    Posted 26 Mar 2014 in reply to SEE Global IT Development Team Link to this post

    Sorry for the badly formatted code blocks in my initial message.
    Also, just to specify, I am using the 2014 Q1 release, 2014.1.225.35.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 28 Mar 2014 Link to this post

    Hello,

    I was able to replicate the described issue and I have forwarded it to our developer team for further investigation. Thank you for pointing this issue out. In addition, I have updated your Telerik Points for reporting for that problem.

    Regards,
    Nencho
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
Back to Top