ASP.NET MVC: calling a controller method from view

Posted by Alice in wonderland on Stack Overflow See other posts from Stack Overflow or by Alice in wonderland
Published on 2010-03-18T20:08:08Z Indexed on 2010/03/19 4:11 UTC
Read the original article Hit count: 200

Filed under:

I'm implementing paging on an ASP.NET MVC view, and I want to call a method in the controller from the view.

Code in the view:

<a href="<%= Url.Action("Search", 
            new { page = NextPage(Request["exactPage"])).ToString()}) %>"> 

Controller method:

public string NextPage(string currentPage)
{
     return (int.Parse(currentPage) +  1).ToString();
}

How can I call the NextPage method from the view?

thanks!

© Stack Overflow or respective owner

Related posts about asp.net-mvc