Here I have an view model
public class SimpleModel { public string Id { get; set; } public string Name { get; set; } } And I passing the my model value,
... var myModel = new SimpleModel() { Id = "1234"; Name = "Dean"; }; return View(..., myModel); Here the problem I faced, I trying to passing the value to a javascript after pressing a button or link, but it fail to work, I doubt did my model contain the value and I double check by display it out, it seems it contain value.
Here the part of my code
... <a href="javascript:functionA(@Model.Name)">Call Function</a> <span>@Model.Name</span> ... If I remove the @Model.Name parameter, it work perfectly. Is there way to fix this? or I did wrong on the part I passing the parameter.
Error I get is
Uncaught SyntaxError: Invalid or unexpected token Any help to this will be appreciated and sorry if I explain the situation bad. Thanks.
href="javascript:functionA('@Model.Name')"