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.
Unfortunately, activation email could not send to your email. Please try again.

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

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.

CSHTML

CS

 

Article ID: Published Date: Last Revised Date: Platform: Control:
3629 01/29/2015 08/19/2015 ASP.NET MVC (Classic) AutoCompleteTextBox
Tags:
Did you find this information helpful?
Comments
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
Add Comment
You must log in to leave a comment

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.