Reputation: 25
This code:
<p class="options">
<a class="btn btn-default btn-lg selector1" @Html.ActionLink("Login", "Login", "Account")></a>
<a class="btn btn-default btn-lg selector2" @Html.ActionLink("Register", "Register", "Account")> </a>
</p>
Gives the error that the paragraph has no closing tag if remove the closing tag after the bracket in both lines. However with the closing tag there it shows up in the application? I've used it elsewhere without the closing tag, i'm unsure why it insists here only to show it?
Upvotes: 1
Views: 73
Reputation: 10819
You are using @Html.ActionLink()
wrong.
ActionLink()
renders a complete anchor tag on the page, you are embedding that tag generation in another tag (which is producing malformed HTML).
What you likely want to do is:
<p class="options">
@Html.ActionLink("Login", "Login", "Account", htmlAttributes: new { @class="btn btn-default btn-lg selector1" })
@Html.ActionLink("Register", "Register", "Account", htmlAttributes: new { @class="btn btn-default btn-lg selector2" })
</p>
Note the htmlAttributes
property. This is where you can pass an anonymous object containing your html attributes. Since your need to account for your class=""
property you can pass it an object that looks like this:
new { @class="btn btn-default btn-lg selector2" }
Remember to use @
at the beginning of "class" because class is a reserved keyword in C# and the @
symbol will "escape" it.
Upvotes: 3