0

I saw this answer here but when I used it in my MVC 5 VS 2013 app it throws "Invalid Character error The char is the @

$(document).on("click", "#btExtendDates", function () {
var _date =  @Html.Raw(Json.Encode(Model.PmntDate)); 

});

Adding quotes doesn't work either. It returns a literal string (Which I believe is correct)

var _date =  '@Html.Raw(Json.Encode(Model.PmntDate))'
Community
  • 1
  • 1
Ben Junior
  • 2,449
  • 10
  • 34
  • 51

1 Answers1

0

@Html.Raw/Json.Encode is an HTML helper which can be used only in .cshtml file.

Please move your js code that refers Html helper classes from JavaScript file to cshtml

or atleast the below part

<script>
 var _date = @Html.Raw(Json.Encode(Model.PmntDate))
</script>
Murali Murugesan
  • 22,423
  • 17
  • 73
  • 120