Tuesday, 17 September 2013

c# mvc4 Html.DropDownListFor calling the controller

c# mvc4 Html.DropDownListFor calling the controller

I have browsed through several posts and several codes and none of them
seems to work.
I need to reload a WebGrid based on a DropDown selected key on same page,
partial views. I am now building the dropdown element and using in the
view:
@Html.DropDownListFor(model => model.Users, Model.Users, new {
autopostback = "true" })
Along with the following javascript code:
<script type="text/javascript">
$(document).ready(function () {
$('select:[autopostback=true],input[type=checkbox]:[autopostback=true],input[type=radio]:[autopostback=true]').live('change',function
() {
$(this).closest('form').submit();
});
});
</script>
Javascript Console at browser says:
Uncaught Error: Syntax error, unrecognized expression:
select:[autopostback=true],input[type=checkbox]:[autopostback=true],input[type=radio]:[autopostback=true]
No calls are being done at Controller. What shall I be doing wrong?
Thanks.

No comments:

Post a Comment