I have a project that it had been developed under MVC1 and after aa few months ago I upgraded it in MVC2.
Everything was well, uppon the day I needed to format my computer.
And what can goes wrong with a format? I don't know Laughing
I have installed the MVC2 after the formating,I import the existing project, I build it, and no error displayed while it been build, but from the time I've uploaded it in the production server I am getting this error.
Method not found: 'System.Web.Mvc.MvcHtmlString System.Web.Mvc.Html.LinkExtensions.RouteLink(System.Web.Mvc.HtmlHelper, System.String, System.Object)'.
I can't understand what caused the problem.
Certainly I assumed that is have to do with MVC1 and I referenced it, but with no luck again.
Theese are the methods that the problem is came from
public static string PagerLinks(this HtmlHelper htmlHelper, string controllerName,
string actionName, int pageCount, int pageIndex, string cssClass, string moreTextCssClass,
string currentPageCssClass, int totalProducts) {
return PagerLinks(htmlHelper, controllerName, actionName, pageCount, pageIndex, "First",
"Previous", "Next", "Last", "more pages", cssClass, moreTextCssClass,
currentPageCssClass, totalProducts);
}
public static string PagerLinks(this HtmlHelper htmlHelper, string controllerName,
string actionName, int pageCount, int pageIndex, string firstPage, string previousPage,
string nextPage, string lastPage, string moreText, string cssClass, string moreTextCssClass,
string currentPageCssClass, int totalProducts) {
var builder = new StringBuilder();
if (String.IsNullOrEmpty(controllerName))
throw new Exception("controllerName and actionName must be specified for PageLinks.");
if (pageCount <= 1)
return String.Empty;
if (String.IsNullOrEmpty(cssClass)) builder.Append("<div>");
else builder.Append(String.Format("<div class=\"{0}\">", cssClass));
builder.Append(string.Format("{0} <b>{1}</b>", "total", totalProducts));
builder.Append("<br />");
if (pageIndex != 1) {
// first page link
builder.Append(
htmlHelper.RouteLink( "First", new {
controller = controllerName,
action = actionName,
id = 1
}, new { title = firstPage }
)
);
////
///
more code
///
///
}
This is the call syntax
<%=Html.PagerLinks((string)ViewData["Controller"], "Page", (int)ViewData["TotalPages"], (int)ViewData["Page"], "theCssClass", "theMoreTextCssClass", "theCurrentPageCssClass", (int) ViewData["TotalProducts"])%>
Inside PagerLinks method exists this line that I supposed that this is , as the error message said, the error.
htmlHelper.RouteLink( "First", new {controller = controllerName,action = actionName,id = 1}, new { title = firstPage })
but the I am getting the error only when i call it via
<%=Html.PagerLinks((string)ViewData["Controller"], "Page", (int)ViewData["TotalPages"], (int)ViewData["Page"], "theCssClass", "theMoreTextCssClass", "theCurrentPageCssClass", (int) ViewData["TotalProducts"])%>
if I comment out the above line and replaced it with the below line just for testing, nothing happens
htmlHelper.RouteLink( "First", new {controller = controllerName,action = actionName,id = 1}, new { title = firstPage })
I'll appreciate any suggestions