I need to call a jquery function through the onchange event of this DropDownList. I’ve googled and googled and can’t find out why my razor syntax is wrong. Help please?
@Html.DropDownListFor(model => model.Type, (List<SelectListItem>)Type, new { @onchange = "reloadDial(" + @Model.AppID, @Model.LoginID, @Model, @ViewBag.Edit + ")"})
The error is in the last part. @ViewBag.Edit + “)”}) Error is “Invalid anonymous type declarator. Anonymous type members must be declared with a member assignment, simple name or member access.”
Looks like the problem is you’re trying to concatenate some arguments for the
javascriptfunction. Your arguments are not in astring, so the compiler thinks you’re trying to add morepropertiesto the anonymousobject.So…
should be: