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

OnTextChange causes loss of Value property?

7 Answers 100 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
mqsash
Top achievements
Rank 1
mqsash asked on 14 Feb 2013, 06:21 PM
Hi 

I'm using v2012.3.1308.35 and am running into an issue where I am getting an empty Value for the selected entry in the autocomplete box.

Here's my markup:
Note that InputType="Text" and I have registered an OnTextChanged handler.

<telerik:RadAutoCompleteBox
  ID="OperatorAutoCompleteBox"
  runat="server"
  DataSourceID="sqlOperatorsLookupList"
  DataTextField="Full_Name"
  DataValueField="Operator_ID"
  Filter="Contains"
  InputType="Text"
  OnTextChanged="OperatorAutoCompleteBox_SelectedOperatorChanged">
 
  <TextSettings SelectionMode="Single" />
 
</telerik:RadAutoCompleteBox>

Now in the codebehind if I do the following, then the selectedText gets the actual selected text but the selectedValue is an empty string.

If OperatorAutCompleteBox.Entries.Count > 0 Then
  selectedText = OperatorAutoCompleteBox.Entries(0).Text
  selectedValue = OperatorAutoCompleteBox.Entries(0).Value
End If

Strangely the Entries(0).Value starts to function normally (i.e return the selected value) if I remove the OnTextChanged="....." line from the markup. So to me it seems like registering the OnTextChanged somehow causes the RadAutoCompleteBox to lose its Value property.

Is this a known bug?
Could this be something from the remains of when InputType="Text" did not support the Value property?

(see: http://www.telerik.com/community/forums/aspnet-ajax/autocompletebox/entry-value-is-empty.aspx#2219318 )

FYI - Switching to InputType=Token, or removing the OnTextChanged is not an option for me as I need to limit a single selection and also use the OnTextChanged to populate other controls on what the user has selected.

Thanks 

7 Answers, 1 is accepted

Sort by
0
Simon
Top achievements
Rank 1
answered on 15 Feb 2013, 10:19 AM
I've noticed a similar behavior. Does my selected item contains one or more apostrophes ("), then I get a blank value after losing focus to the control. In debug mode I could see, that the OnTextChanged event is not fired.

Thanks for your help
0
mqsash
Top achievements
Rank 1
answered on 15 Feb 2013, 05:00 PM
No, I don't have apostrophes in the selected text nor values.The text is just regular names and the values are integer IDs.
Also the same data works fine when I do no define the OnTextChangedHandler in the markup for the RadAutoCompleteBox, so I am inclined to think that this has something to do with how the Rad control registers this handler.

0
Nencho
Telerik team
answered on 19 Feb 2013, 12:57 PM
Hello S S,

The described problematic behavior is a bug. I have forwarded it to our developer team for further consideration. Thank you for reporting for that issue. In addition, your Telerik Points are updated.

Kind regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Tom
Top achievements
Rank 1
answered on 24 Apr 2014, 01:11 PM
Has this been resolved? I have the same issue but with the event being triggered from a radgrid.
0
Nencho
Telerik team
answered on 29 Apr 2014, 08:43 AM
Hello Tom,

I can confirm that the reported in this thread bug is already fixed. Could you elaborate a bit more on your scenario and what exactly is the faced issue?

Regards,
Nencho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Tom
Top achievements
Rank 1
answered on 29 Apr 2014, 02:32 PM
Hi Nencho,

I have an autocompletebox in a grid templatecolumn. The grid is setup with an Ajax callback using the AjaxManager.

<telerik:RadAutoCompleteBox runat="server" ID="customersDDL" AutoPostBack="true" OnTextChanged="customersDDL_TextChanged" OnClientRequesting="requesting" InputType="Text" Width="300px" TextSettings-SelectionMode="Single">
                                    <WebServiceSettings Method="GetCustomerList" Path="AccountingSync.aspx" />
                                </telerik:RadAutoCompleteBox>

How do I get the Value (ID) of the entry? The only option I get in the callback AutoCompleteTextEventArgs is to retrieve the Text. I need to check the Value to see if it is being used somewhere else already and notify the user that the selected item is already being used somewhere...they can still continue to use so the message is just informational.

Thanks,
Tom
0
Nencho
Telerik team
answered on 01 May 2014, 01:54 PM
Hello Tom,

You could access the value, by using the Entries collection of the RadAutoCompleteBox. Please consider the following implementation for the TextChanged event:

protected void customersDDL_TextChanged(object sender, AutoCompleteTextEventArgs e)
      {
          RadAutoCompleteBox autoComplete = sender as RadAutoCompleteBox;
          string value = autoComplete.Entries[0].Value;
      }

Regards,
Nencho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
AutoCompleteBox
Asked by
mqsash
Top achievements
Rank 1
Answers by
Simon
Top achievements
Rank 1
mqsash
Top achievements
Rank 1
Nencho
Telerik team
Tom
Top achievements
Rank 1
Share this question
or