Reputation: 1237
I have Serverside code that is coming from Controller method as below in ViewData.
"{'Double-Click to edit':'','7C486':'7C486','7C489':'7C489','7C490':'7C490','7C491':'7C491','7C492':'7C492'}";
But I have to display these values into Dropdown that is in Jquery Editable Grid. I am accessing the code from Server to Jquery as here:
var reasonCd = '@ViewData["ReasonCodes"].ToString()';
and the value is:
reasonCd = '{'Double-Click to edit':'','7C486':'7C486','7C489':'7C489','7C490':'7C490'}';
Not sure why it is decoding like this. Now I have to replace & #39; with single quote.
I tried this:
reasonCd.replace("'", "'");
But it is erroring out.
Highly appreciate your responses.
Upvotes: 1
Views: 789
Reputation: 9530
Try using the Html.Raw()
method to prevent HTML encoding of the data.
var reasonCd = '@Html.Raw(ViewData["ReasonCodes"].ToString())';
Upvotes: 2