BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
Hi Prasanthan,
Thanks for contacting Syncfusion support.
We can get the ID of the selected item using the “getSelectedItems()” method. In the “select” event of the Autocomplete, we can pass the value to the server side. Please refer the below code snippets,
[View]
@Html.EJ().AutocompleteFor(model => model.value, (Syncfusion.JavaScript.Models.AutocompleteProperties)ViewData["auto"]) |
<script> var key, selectedItems, autocompleteobj; function onSelect(args) { key = []; //Object for Autocomplete created autocompleteobj = $("#value").data("ejAutocomplete"); //get the data from getSelectedItems() selectedItems = autocompleteobj.getSelectedItems(); //Key is obtained here var itemId = selectedItems[0].uniqueKey; $.ajax({ url: '/Autocomplete/ID', type: 'POST', data: { id: itemId }, success: function (result) { alert("ID posted sucessfully"); }, error: function (e) { console.log(e); } }); } </script>
|
[controller]
public ActionResult Index() { AutocompleteProperties auto = new AutocompleteProperties(); auto.DataSource = GetDataSource(); auto.FilterType = FilterOperatorType.Contains; AutocompleteFields fld = new AutocompleteFields(); auto.Select = "onSelect"; ViewData["auto"] = auto;
return View(); } |
We have also attached a sample for your reference, please check it.
Sample Location: autocompleteFor sample
http://help.syncfusion.com/aspnetmvc
Our EJMVC components are created as wrapper for the JavaScript components. So the API, and events will be the same in both JS and EJMVC components. You can refer the following API reference section present in our online JS help document to know about the list of API’s, methods and events supported by each components.
http://docs.syncfusion.com/js/api/ejaccordion
Regards,
HariKrishnan
Hi Prasanthan,
Thanks for your update.
We need to bind the “Project” class in the controller action during HttpPost, so the Autocomplete selected value will be automatically populated in the controller action. Please refer the below code snippet,
[HttpPost] public ActionResult ProjectDetails(Project model) { ViewBag.LeaderName = model.Leader; return View(model); }
|
In the “model” you will get the values of all the properties in the “Project” class. We have attached a sample for your reference, please check it.
Sample Location: AutocompleteFor sample
If you need further assistance, kindly get back to us with more information and we will be happy to help you.
Regards,
HariKrishnan