-1

I want to access model data from javascript Accessing MVC's model property from Javascript my problem is similar to this but whenever i use the solution given here

var model = @Html.Raw(Json.Encode(Model));

or

var floorplanSettings = @Html.Raw(Json.Encode(Model.FloorPlanSettings));

it returns null exception ... where as i already have data in database. other solution such as var Name = '@Model.Name';show syntax error .... what is the solution for this?? can anyone help me with this!!

p.bajra
  • 1
  • 1
  • If your getting a `NullReferenceException`, then the model is `null` in your view! –  Jun 16 '18 at 07:16

1 Answers1

0

Does this produce the expected result?

var model = @(new HtmlString(Json.Encode(Model)));

 

Dacre Denny
  • 29,664
  • 5
  • 45
  • 65