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.

generic dropdown for mvc get selected value

Thread ID:

Created:

Updated:

Platform:

Replies:

108410 Apr 18,2013 01:37 PM Dec 8,2015 03:13 AM ASP.NET MVC (Classic) 3
loading
Tags: Tools
helmishariff
Asked On April 18, 2013 01:37 PM

How I can get value using javascript and server side for selected generic dropdown. I have no problem to get the selected text.

Varalakshmi R.S [Syncfusion]
Replied On April 22, 2013 07:07 AM

Hi helmishariff,

 

Thanks for contacting Syncfusion forums.

 

You can get the selected value of the GDD via script in the ClientSideOnClick event. “args._text “ returns currently selected items text. To retrieve the currently selected items text in serverside, first append the text to textbox and then access it in the action using its controls id. Please refer the below given code snippet to achieve this,

<code>

[Script]

function ClientSideOnClick(sender, args) {

        var text = args._text;//return selected text

    }

 

[Controller]

[HttpPost]

        public ActionResult Index(string genericdropdownId)

        {

            //genericdropdownId returns text

            return View();

        }

</code>

 

Kindly try the above methods and let us know if you have any other queries.

 

Regards,

Varalakshmi


Manish
Replied On December 4, 2015 12:51 AM

Hi,

I am unable to get the value from selected DropDownList in JavaScript.

My Snippet:
    function FromCountryChange(sender, args) {  //here both object (sender & args) is null
        $.ajax({
            url: '/PurchaseRequest/GetListOfStates',
            data: { countryCode: 1 },
            error: function (a, b, c) {
                debugger;

            },
            success: function (data1, b, c) {
                debugger;
                $("#FromState").ejDropDownList({
                    dataSource: data1
                });
            }
        });
    }

@Html.EJ().DropDownListFor(model => model.FromCountry).CascadeTo("FromState").WatermarkText("Select From Country").AllowVirtualScrolling(true).VirtualScrollMode(VirtualScrollMode.Normal).DropDownListFields(f => f.Value("Code")).DropDownListFields(f => f.Text("Name")).EnableAnimation(true).EnableIncrementalSearch(true).CaseSensitiveSearch(false).Width("400").ClientSideEvents(evt => evt.Change("FromCountryChange")).Datasource(ViewBag.Countries)

Varalakshmi R.S [Syncfusion]
Replied On December 8, 2015 03:13 AM

Hi Helmishariff,

Thanks for your interest in Syncfusion products.

We are able to retrieve the selected value from change event args “sender”. We have also prepared a simple sample to exhibit this behavior and the sample can be downloaded from the link given below,
http://www.syncfusion.com/downloads/support/forum/108410/ze/Dropdown690932512




You can refer the API reference details from the below given link,
http://help.syncfusion.com/js/api/ejdropdownlist#events:change

Could you please try the sample and if the issue exists still could you please let us the version used in your application? Or please share the application in which this issue was reproduced. We will check the application and update the details to you.

Regards,
Varalakshmi

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;