With the following code:
<script type="text/javascript" src="../../Scripts/jquery-1.4.1.js" />
<script type="text/javascript">
$(function () {
$('#selectOptions').change(function () {
$(this).parents('form').submit();
});
});
</script>
...
<% using (Html.BeginForm("PostedValue", "Home"))
{ %>
<%: Html.DropDownList("selectOptions", new List<SelectListItem>
{ new SelectListItem{ Text="1", Value="1"},
new SelectListItem{ Text="2", Value="2"},
new SelectListItem{ Text="3", Value="3"}},
"Select List")%>
<%} %>
</div> </body>
</html>
What am I doing wrong?
when I do the following it works
{ new SelectListItem{ Text="1", Value="1"}, new SelectListItem{ Text="2", Value="2"}, new SelectListItem{ Text="3", Value="3"}}, "Select List", **new { onchange = "$(this).parents('form').submit()"** })%>I am wondering why $function() is not working..