0

I am trying to build a string that gets passed to a graph and rendered. But the string gets encoded to have html codes, instead of the inverted comma.

I build like this:

foreach (var i in result)
{
   items += string.Format("[\'{0}\', {1}],", i.Date.ToShortDateString(), i.Balance);
}

But on the page, the output is this:

['24/12/2013', -20.82],['25/12/2013', -20.82],['26/12/2013', -47.82],...

The script accepting the script looks like this:

 $.jqplot('chartdiv', [[@Model.data]],

How do I keep the formatting I expect?

1 Answer 1

2

Have you tried using Html.Raw?

Html.Raw(yourValue); 

So in your case it would be:

$.jqplot('chartdiv', [[@Html.Raw(Model.data)]],
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.