It's great we have the Html.If helper extension, but why does it return an encoded value when you have a true/false value and not encoded when there's only a true value? It's really messing up my templates.
public static IHtmlString If(this HtmlHelper html, bool test, string valueIfTrue)
{
return If(html, test, valueIfTrue, string.Empty);
}
/// <summary>
/// If <paramref name="test" /> is <c>true</c>, the HTML encoded <paramref name="valueIfTrue" /> will be returned; otherwise, <paramref name="valueIfFalse" />.
/// </summary>
/// <param name="html">The HTML helper.</param>
/// <param name="test">If set to <c>true</c> returns <paramref name="valueIfTrue" />; otherwise, <paramref name="valueIfFalse" />.</param>
/// <param name="valueIfTrue">The value if <c>true</c>.</param>
/// <param name="valueIfFalse">The value if <c>false</c>.</param>
/// <returns>
/// The HTML encoded value.
/// </returns>
public static IHtmlString If(this HtmlHelper html, bool test, string valueIfTrue, string valueIfFalse)
{
return new HtmlString(HttpUtility.HtmlEncode(test ? valueIfTrue : valueIfFalse));
}
Html.If UrlEncoded
It's great we have the Html.If helper extension, but why does it return an encoded value when you have a true/false value and not encoded when there's only a true value? It's really messing up my templates.
is working on a reply...