I'm trying to create a helper function within ASP.NET MVC and pass a model along with one of its attributes as parameters. I'm trying to mimic some of the other helper functions that already exist within this project I'm working on but I keep getting Context errors.
EDIT:
Here is the helper function I am trying to create:
public static MvcHtmlString PreviousPage(this HtmlHelper helper, IPagedList<QuestionAnswerModel> Answers, int pageCount)
{
var tag = new TagBuilder("link");
tag.MergeAttribute("rel", "prev");
return MvcHtmlString.Create(tag.ToString());
}
And I am trying to access this helper within my View using Razor:
@{ @Html.PreviousPage(Model.Answers, Model.Answers.PageCount) }
EDIT:
Here is the error I am receiving and it is happening from my View code above:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'HtmlHelper<QuestionAnswersModel>' does not contain a definition for 'PreviousPage' and no extension method 'PreviousPage' accepting a first argument of type 'HtmlHelper<QuestionAnswersModel>' could be found (are you missing a using directive or an assembly reference?)
I know this syntax isn't correct but I do know that my Model is correct and these attributes are defined properly.
Any help is greatly appreciated!