ASP.NET MVC: Display a link to another action
@Html.ActionLink("Add a bill", "Create", new { controller = "Bill"});
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 (/Bi开发者_JAVA技巧ll/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" })
and:
@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" />
}
精彩评论