Hello,
I am quite new to ASp.net MVC so it might be really trivial for you. Still, I have this question to ask : I want to display an image or not according to a booleean.
With classis asp.net, i was databinding the visible property with my boolean and then Hop, the trick was done. But here it doesn't work this way. I have browsed the web and found this way of dealing with it :
<%= Html.Image(this.ResolveUrl("~/attention.gif"),"dates invalid",myboolean) %>
with a Html hepler of this kind :
public static string Image(this HtmlHelper helper,
string url,
string altText,
bool IsVisible)
{
string returnvalue = string.Empty;
if (IsVisible)
{
TagBuilder builder = new TagBuilder("image");
builder.Attributes.Add("src", url);
builder.Attributes.Add("alt", altText);
builder.MergeAttributes(new RouteValueDictionary(htmlAttributes));
returnvalue = builder.ToString(TagRenderMode.SelfClosing);
}
return returnvalue;
}
Am I doing right or is there something easier I didn't get?