3
@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 (/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.

1 Answer 1

4

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" />
}
Sign up to request clarification or add additional context in comments.

2 Comments

Yeah, In html source, I see "<a href="/Bill/Create">Add a bill</a> " But browser rendered as that what I said.
@user469652, yes it is possible that it is a CSS issue. Try disabling all style sheets temporary to see if this makes any difference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.