Posting selected item from dropdown to controller using ajax

Hi

I was wondering if I could get some help in posting the currently selected dropdown item using ajax on .net core 3.1 application. The user will select an item for the dropdown and I need to post this id back to my controller and receive a response. I tried using the below syntax but .data is not working for me


Any help appreciated


RJ


Attachment: html_selected_dropdown_a9277521.zip

1 Reply 1 reply marked as answer

SP Sureshkumar P Syncfusion Team April 5, 2022 01:47 PM UTC

Hi RJ,


Based on your shared images, you can get the component instance value by using below code example instead of you have used Essential JavaScript 1 instance method.


Find the code example here:

<ejs-dropdownlist id="vegetable" dataSource="@ViewBag.data" placeholder="Select a vegetable" popupHeight="220px">

            <e-dropdownlist-fields value="Vegetable"></e-dropdownlist-fields>

        </ejs-dropdownlist>

        <ejs-button id="butn" onclick="onRestore()" content="resetclick"></ejs-button>

 

        <script>

            function onRestore(){

                // get the instance using ej2_instance method

                var instance = document.getElementById("vegetable").ej2_instances[0];

                console.log(instance);

            }

        </script>

 

 


Regards,

Sureshkumar P


Marked as answer
Loader.
Up arrow icon