My own HtmlHelper don't work in Asp.Net MVC 2

Posted by name1ess0ne on Stack Overflow See other posts from Stack Overflow or by name1ess0ne
Published on 2010-05-22T13:58:33Z Indexed on 2010/05/22 14:00 UTC
Read the original article Hit count: 222

Filed under:

I have HtmlHelper in ASP.NET MVC 1. Now I wont to migrate to ASP.NET MVC 2, but this helper don't work =(


public static string Image(this HtmlHelper helper, string url, string alt)
{
    return string.Format("<img src=\"{0}\" alt=\"{1}\" />", url, alt);
}

public static string ImageLink<T>(this HtmlHelper helper, Expression<Action<T>> linkUrlAction, string imageUrlPath, string altText)
    where T : Controller
{
    string linkUrl = helper.BuildUrlFromExpression(linkUrlAction);//compile time error
    string img = helper.Image(imageUrlPath, altText);

    string outputUrl = string.Format(@"<a href='{0}'>{1}</a>", linkUrl, img);
    return outputUrl;
}

Error: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'BuildUrlFromExpression'

How I can fix this error?

© Stack Overflow or respective owner

Related posts about asp.net-mvc