Skip to main content
added 43 characters in body
Source Link
Rajshekar Reddy
  • 19.1k
  • 4
  • 45
  • 64
  • Use quotes for non numeric datatypedataType.
  • Do Not use quotes for numeric dataType.
  • Use Html.Raw to interpret your HTML data as is.
  • Take care of your HTML data to either escape the quotes meaning in server side, Or use a different quote than in data during assignment to javascript variable.

As you have already encountered this entity Name issue whichwith property assignment and if you remember we overcame it with the use of Html.Raw. So lets try that out. Lets combine Html.Raw and Json.Encode

  • Use quotes for non numeric datatype.
  • Use Html.Raw to interpret your HTML data as is.
  • Take care of your HTML data to either escape the quotes meaning in server side, Or use a different quote than in data during assignment to javascript variable.

As you have already encountered this entity Name issue which property assignment and if you remember we overcame it with the use of Html.Raw. So lets try that out. Lets combine Html.Raw and Json.Encode

  • Use quotes for non numeric dataType.
  • Do Not use quotes for numeric dataType.
  • Use Html.Raw to interpret your HTML data as is.
  • Take care of your HTML data to either escape the quotes meaning in server side, Or use a different quote than in data during assignment to javascript variable.

As you have already encountered this entity Name issue with property assignment and if you remember we overcame it with the use of Html.Raw. So lets try that out. Lets combine Html.Raw and Json.Encode

added 50 characters in body
Source Link
Rajshekar Reddy
  • 19.1k
  • 4
  • 45
  • 64
public class AppUser { public string Name { get; set; } public bool IsAuthenticated { get; set; } public DateTime LoginDateTime { get; set; } public int Age { get; set; }  public string UserIconHTML { get; set; } } 
public class AppUser { public string Name { get; set; } public bool IsAuthenticated { get; set; } public DateTime LoginDateTime { get; set; } public int Age { get; set; } } 
public class AppUser { public string Name { get; set; } public bool IsAuthenticated { get; set; } public DateTime LoginDateTime { get; set; } public int Age { get; set; }  public string UserIconHTML { get; set; } } 
added 3 characters in body
Source Link
Rajshekar Reddy
  • 19.1k
  • 4
  • 45
  • 64
<script type="txttype="text/javascript"> var userObj = @Html.Raw(Json.Encode(Model)); //For javascript object var userJsonObj = '@Html.Raw(Json.Encode(Model))'; //For json data </script> 
<script type="txt/javascript"> var userObj = @Html.Raw(Json.Encode(Model)); //For javascript object var userJsonObj = '@Html.Raw(Json.Encode(Model))'; //For json data </script> 
<script type="text/javascript"> var userObj = @Html.Raw(Json.Encode(Model)); //For javascript object var userJsonObj = '@Html.Raw(Json.Encode(Model))'; //For json data </script> 
added 1 character in body
Source Link
Rajshekar Reddy
  • 19.1k
  • 4
  • 45
  • 64
Loading
deleted 1 character in body
Source Link
Rajshekar Reddy
  • 19.1k
  • 4
  • 45
  • 64
Loading
added 142 characters in body
Source Link
Rajshekar Reddy
  • 19.1k
  • 4
  • 45
  • 64
Loading
added 199 characters in body
Source Link
Rajshekar Reddy
  • 19.1k
  • 4
  • 45
  • 64
Loading
added 199 characters in body
Source Link
Rajshekar Reddy
  • 19.1k
  • 4
  • 45
  • 64
Loading
added 199 characters in body
Source Link
Rajshekar Reddy
  • 19.1k
  • 4
  • 45
  • 64
Loading
added 1879 characters in body
Source Link
Rajshekar Reddy
  • 19.1k
  • 4
  • 45
  • 64
Loading
Source Link
Rajshekar Reddy
  • 19.1k
  • 4
  • 45
  • 64
Loading