ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
binding to AjaxDropdown change and get value
Title:
B
I
{code}
?
this is my code: @(Html.Awe().AjaxDropdownFor(o => o.Audience) .HtmlAttributes(new { @id = "AudienceType", Title = "Choose Audience Type" }) .Url(Url.Action("GetAudiencesList", "Data"))) <script type="text/javascript"> var selectedAudience = 0; $(function () { // Function triggered by change in the AudienceType dropdown list $('#AudienceType').change(function () { selectedAudience = $(this).val(); }); }; </script>
Save Changes
Cancel
Tim
asked at 23 Feb 2016
Answers
B
I
{code}
?
if `$('#Audience').change` doesn't work for you, maybe you have more than one #Audience in your document anyway you can change the html id by using `.Prefix(string)`, or like this: `.HtmlAttributes(null, new { @id = "AudienceType" })` here's a demo for this: http://www.youtube.com/watch?v=uxvV_lCfuik
Save Changes
Cancel
Omu
answered at 24 Feb 2016
Thanks so much, the function picked up the value correctly by changing to HtmlAttributes(null, new { @id = "AudienceType" }) I have been scratching my head for the whole day over it. Your help is much appreciated.
at 24 Feb 2016
Tim
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK