i have an action like below in my controller and the object of one Viewmodel class i had send as an argumnet to view. The problem is i need to get this object values in javascript.
public ActionResult FillChecklist()
{
classOne objVM=new classone();
objVM.List=//get list
objVM.Id=//someid
objVM.List2=//secondlist
return View(objVM);
}
i had tried something like below but it does not works. i know hidden variable assign is a solution but i don't know if model class has many lists then how can i get the list in javascript.
<script type="text/javascript>
var obj=@Model;
</script>
i had tried the below method too. but it shows the name json is not exist in this current context
var obj = JSON.parse('@Html.Raw(Json.Encode(Model))');
please help me to solve this issue.