Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

asp.net mvc - Create a T4MVC ActionLink with url fragment

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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) %>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...