开发者

Need Help on a custom HTML Helper

I'm trying to create a custom HTML Helper to help simplify my masterpages menu, however it is not rendering on the HTML开发者_JAVA百科 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"); %>

Thanks: Dave Swersky

Fix was: I forgot the equals and removed the semi-colon

<%= 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?


Modify your markup:

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

The equals sign and no semicolon should do the trick.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜