c# - Output Raw String in ASP.NET MVC Razor -


this question has answer here:

i have site built asp.net mvc. have string in view model looks this:

viewbag.text = "{\"1\":{\"1\":\"john\",\"2\":\"bill\",\"3\":\"paul\"},\"3\":{}}"; 

i want output view this:

<input id='myhiddeninput' type='hidden' value='@viewbag.text' /> 

when view gets rendered, hidden element looks this:

<input id='myhiddeninput' type='hidden' value='{&quot;1&quot;:{&quot;1&quot;:&quot;john&quot;,&quot;2&quot;:&quot;bill&quot;,&quot;3&quot;:&quot;paul&quot;},&quot;3&quot;:{}}' /> 

how update view output looks following:

<input id='myhiddeninput' type='hidden' value='{"1":{"1":"john";,"2":"bill","3":"paul"},"3":{}}' /> 

i know seems goofy. need though.

you can use html.raw output unencoded data:

<input id='myhiddeninput' type='hidden' value='@html.raw(viewbag.text)' /> 

here link dotnetfiddle. can see output in text field, there hidden field same unencoded information.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -