Need Help on a custom HTML Helper

Posted by LeeHull on Stack Overflow See other posts from Stack Overflow or by LeeHull
Published on 2010-03-30T18:57:24Z Indexed on 2010/03/30 19:03 UTC
Read the original article Hit count: 422

I'm trying to create a custom HTML Helper to help simplify my masterpages menu, however it is not rendering on the HTML when I use it.. I'm thinking I will need to create a partial view, any ideas?

I did this..

    public static string CreateAdminMenuLink(this HtmlHelper helper, string caption, string link)
    {
       var lnk = TagBuilder("a");
       lnk.SetInnerText(caption);
       lnk.MergeAttribute("href", target);
       return lnk.ToString(TagRenderMode.SelfClosing);
    }

Now in my View, i have

<% Html.CreateAdminMenuLink("Home", "~/Page/Home"); %>

but when I look at the source, its empty.. tried adding <% using (Html.BeginForm()) %> and it adds a form.. but the link still doesnt come up.. debugged and the string works when i look at the watch, but does not render..

Any ideas?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about asp.net-mvc-views