I am using EF4 + MVC 3 with Razor.
I have the following ActionResult
, which renders a Dictionary<string,string>
into a partial view.
ACTION
public ActionResult combotest()
{
Dictionary<string, string> r = new Dictionary<string, string>();
r.Add("<> ''", "T");
...
return PartialView("_mypartial", r);
}
Now, special chars contained into the Model.Key
values are HTML Encoded, while I'd like to use them as plain text. For example <> ''
is rendered as <> ''
.
I tried to convert them with WebUtility.HtmlDecode
or Server.HtmlDecode
without success:
PARTIAL VIEW (_mypartial):
<select>
<option value=''></option>
@foreach (KeyValuePair<string,string> value in (Dictionary<string, string>)Model)
{
<option value="@WebUtility.HtmlDecode(value.Key)">@value.Value
</option>
}
</select>
Could you help me? I would avoid to use String.Replace
, if possible.
To display text unencoded you can use @Html.Raw(value.key)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With