Calling Html.ActionLink in a custom HTML helper
Posted
by Sylvain
on Stack Overflow
See other posts from Stack Overflow
or by Sylvain
Published on 2010-03-04T13:08:09Z
Indexed on
2010/06/16
14:12 UTC
Read the original article
Hit count: 337
asp.net-mvc
|htmlhelper
I am designing a custom HTML helper and I would like to execute Html.ActionLink to provide dynamic URL generation.
namespace MagieMVC.Helpers
{
public static class HtmlHelperExtension
{
public static string LinkTable(this HtmlHelper helper, List<Method> items)
{
string result = String.Empty;
foreach (Method m in items)
{
result += String.Format(
"<label class=\"label2\">{0}</label>" +
System.Web.Mvc.Html.ActionLink(...) +
"<br />",
m.Category.Name,m.ID, m.Name);
}
return result;
}
}
}
Unfortunately Html.ActionLink is not recognized in this context whatever the namespace I have tried to declare.
As a generic question, I would like to know if it is possible to use any existing standard/custom Html helper method when designing a new custom helper.
Thanks.
© Stack Overflow or respective owner