user6656728
user6656728

Reputation:

@Html.ActionLink not working in mvc-5

i am creating a web app in mvc-5

here is my actionlink button which looks like

<p>
    <span class="btn btn-success glyphicon glyphicon-plus">
        @Html.ActionLink(" ", "insert")
    </span>
</p>

when a user clicks on this button he should be redirected to the following page

public ActionResult insert()
        {
            return View();
        }

but nothing is happening when i am clicking the button

what i need to do?

Upvotes: 1

Views: 3582

Answers (2)

user3559349
user3559349

Reputation:

Because you not generating any text in the link, there is nothing to 'click'.

Change your code to generate a link containing the <span> element

<p>
    <a href="@Url.Action("insert")">
        <span class="btn btn-success glyphicon glyphicon-plus"></span>
    </a>
</p>

Upvotes: 1

Wheels73
Wheels73

Reputation: 2890

Your link format doesn't look correct.

You've only got

 @Html.ActionLink(" ", "insert")

Add your "Link text", action and controller name and you should be ok.

@Html.ActionLink("Link Text", "YourAction", "YourController")

NOTE : There are 9 overloads for ActionLink allowing you to omit the controller (among other things )if the link target is handled by the same controller.

Hope that helps

Upvotes: 3

Related Questions