Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is there a way to create a strongly typed T4MVC ActionLink with a hash/pound/fragment in it?

For example, here is the link I'd like to create:

<a href="/Home/Index#food">Feed me</a>

But there's no extension to the T4MVC object that can do this.

<%= Html.ActionLink("Feed me", T4MVC.Home.Index()) %>

So, what I end up having to do is create an action, and then embed it that way:

<a href="<%= Url.Action(T4MVC.Home.Index()) %>"#food>Feed me</a>

This isn't very desirable. Anyone have any ideas/suggestions?

Thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

In ASP.NET MVC 2.0 new helpers have been added that allow you to specify the fragment. Example:

<%= Html.ActionLink("Feed me", "Action", "Controller", null, null, "food", null, null) %>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...