Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net C# Razor showing encoded HTML instead of raw html

I'm using the JQM-DateBox - which needs the following Razor markup:

@Html.TextBoxFor(m => m.From, new { @name = "mydate", @id = "mydate",  
@data_role = "datebox", 
@data_options = "{'mode':'flipbox', 'dateFormat':'dd/mm/YYYY' ,'useNewStyle':true} ")

However, this renders as:

 <input data-options=" {&#39;mode&#39;:&#39;flipbox&#39;, &#39;dateFormat&#39;:&#39;dd/mm/YYYY&#39; ,&#39;useNewStyle&#39;:true} " 
data-role="datebox" id="mydate" 
name="From" type="text" value="29/08/2013 00:00:00" />

I know you can use html.raw - but how do you use it within a helper?

I need to show:

{'mode':

...instead of...

{&#39;mode&#39;:

like image 782
Mark Avatar asked Aug 29 '13 19:08

Mark


1 Answers

Try @Html.Raw(HttpUtility.HtmlDecode(@Html.TextBoxFor(...).ToHtmlString())).

like image 91
Vladimir Avatar answered Sep 28 '22 03:09

Vladimir