public static ConditionalLink BeginConditionalLink(this HtmlHelper helper, bool shouldWriteLink, IHtmlString url, string title = null, string cssClass = null)
{
if(shouldWriteLink)
{
var linkTag = new TagBuilder("a");
linkTag.Attributes.Add("href", url.ToHtmlString());
if(!string.IsNullOrWhiteSpace(title))
{
linkTag.Attributes.Add("title", helper.Encode(title));
}
if (!string.IsNullOrWhiteSpace(cssClass))
{
linkTag.Attributes.Add("class", cssClass);
}
helper.ViewContext.Writer.Write(linkTag.ToString(TagRenderMode.StartTag));
}
return new ConditionalLink(helper.ViewContext, shouldWriteLink);
}