c# - Output Raw String in ASP.NET MVC Razor -
this question has answer here:
- emitting unencoded strings in razor view 4 answers
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='{"1":{"1":"john","2":"bill","3":"paul"},"3":{}}' /> 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
Post a Comment