Custom HTML Helpers in ASP.NET MVC 2
- by Interfector
Hi,
I want to create a pagination helper. The only parameters that it needs are currentpage, pagecount and routename.
However, I do not know if it is possible to use the return value of another html helper inside the definition of my html helper. I am referring specifically to Html.RouteLink. How can I go about doing something like this in the class definition
using System;
using System.Web.Mvc;
namespace MvcApplication1.Helpers
{
public static class LabelExtensions
{
public static string Label(this HtmlHelper helper, string routeName, int currentpage, int totalPages)
{
string html = "";
//Stuff I add to html
//I'd like to generate a similar result as the helper bellow
html .= Html.RouteLink( pageNo, routeName, new { page = pageNo - 1 } );
//Other stuff I do the html
return html;
}
}
}
Thank you.