I'm having a problem with the MVC3 MusicStore tutorial. It defines an HtmlHelper with a Truncate method. The helper looks like this:
using System.Web.Mvc;
namespace MusicStore.Helpers
{
public class HtmlHelpers
{
public static string Truncate(this HtmlHelper helper, string input, int length)
{
if (input.Length <= length)
{
return input;
}
else
{
return input.Substring(0, length) + "...";
}
}
}
}
In the view, I import it using @using MusicStore.Helpers, and then try to use it with <td>@Html.Truncate(item.Title, 25) </td>
However the compiler tells me no such method (Truncate) exists, and seems to be looking for Truncate on IEnumerable[MvcMusicStore.Models.Album] (which is my model) rather than on my HtmlHelpers class.
(NB the square brackets above are really angled brackets in my code, couldnt escape them)
Can anyone tell me what I'm doing wrong please?