ASP.NET MVC:显示一个链接到另一个动作 [英] ASP.NET MVC: Display a link to another action
本文介绍了ASP.NET MVC:显示一个链接到另一个动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@Html.ActionLink("Add a bill", "Create", new { controller = "Bill"});
这是code口用于添加链接比尔控制器创建方法。
This is the code I used to add an link to Create method in Bill controller.
不过,在视图中我看到了
But in the view I saw
Add a bill (/Bill/Create):
所以,我怎么能去掉括号? (/比尔/创建)。
So, how can I remove the brackets? (/Bill/Create).
和,我也希望这个链接作为一个按钮,而不是一个,我该怎么办呢?感谢您的帮助。
And, I also want this link to act as a button instead of a , how can I do that? Thanks for your help.
推荐答案
有什么奇怪的括号你正在谈论。假设默认路由两种:
It is strange what brackets you are talking about. Assuming the default routes both:
@Html.ActionLink("Add a bill", "Create", new { controller = "Bill" })
和
@Html.ActionLink("Add a bill", "Create", "Bill")
是等价的,应该产生以下标记:
are equivalent and should generate the following markup:
<a href="/Bill/Create">Add a bill</a>
至于你对按钮的问题是有关您可以使用的形式:
As far as your question about the button is concerned you could use a form:
@using (Html.BeginForm("Create", "Bill"))
{
<input type="submit" value="Add a bill" />
}
这篇关于ASP.NET MVC:显示一个链接到另一个动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文