We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How should I send the Key value of the selected item in AutoComplete Textbox to controller instead of the Text value?

Platform: ASP.NET MVC (Classic) |
Control: AutoCompleteTextBox
Tags: autocomplete

By default, you can only access the Text value of AutoComplete in the Controller page on post action. In order to get the Key value of the selected item from AutoComplete in the Controller page, you have to pass the Key value through client-side events.

The Key value of the selected item is obtained from OnValueChange event using the event arguments. You can fetch the corresponding selected items Key value in the client-side script, using the event argument property _dataIdItem or the method get_DataId().

From the client-side, button-click event trigger, the AJAX post to pass the variable holds the Key value. Now the value stored in the OnValueChange event is passed to controller using AJAX post where you can get the Key Value of the selected AutoComplete item. Refer the following code example.




You must log in to leave a comment
Jeff Poole
Aug 18, 2015
This example is incomplete, therefore it does not work. Where is the object ACSugg defined? Without seeing this, the AutocompleteActionResult does not seem to pick up the DataIdField, DataTextField, and DataValueField aspects of the control. Current Syncfusion online documentation only mentions these but does not include ANY information on what they do. As such, this example will produce a HTTP 200 response with no data. Reply

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile