Is it possible to cause a postback to an action from changing your selection in a dropdown list without using JavaScript?
I remember when using the ASP.NET Forms dropdown list control, there was a property that when set would cause a postback on change, did this work without JS? - If so, how?
Many thanks, Kohan.
Is it possible to cause a postback to an action from changing your selection in a dropdown list without using JavaScript?
I remember when using the ASP.NET Forms dropdown list control, there was a property that when set would cause a postback on change, did this work without JS? - If so, how?
Many thanks, Kohan.
Share Improve this question edited Dec 22, 2010 at 15:51 Leniel Maccaferri 102k46 gold badges378 silver badges493 bronze badges asked Dec 22, 2010 at 15:41 4imble4imble 14.4k15 gold badges76 silver badges132 bronze badges4 Answers
Reset to default 6You can achieve the postback effect using jQuery. JavaScript in some form or another is required for automatic postbacks. Even ASP.NET uses JavaScript in the background to implement the AutoPostBack property.
<script type='text/javascript'\>
$('#dropDown').change(function () {
$(this).parents('form').submit();
});
</script>
You need JavaScript to automatically post back data. You don't have to write it, but you still need it. You can post without JavaScript (someone pressing a submit button), but not automatically.
I believe what you are thinking of is the AutoPostBack property.
Do this:
More here:
How do you submit a dropdownlist in asp mvc
Complete script which worked for me
@Html.DropDownList("Projects", Model.Projects, new {
style = "Height: 25px; width: 225px;",
onchange = "$(this).parents('form').submit();" })