0

Currently, I have the following code for a button with some text and a model variable inside a <span> tag:

   <button class="cart-icon fr btn btn-info" type="button">
           Cart <span class="badge cart-count">@Model.CartCount</span>
    </button>

enter image description here

I want to be able to link this button to the Index action of the ShoppingCart controller.

It should look like something like this, but I'm not completely sure on how to access the span tag with the html helper:

@Html.ActionLink("Cart", "Index", "ShoppingCart", new { @Model.CartCount}, new { @class = "cart-icon fr btn btn-info"})

I want to ensure I have the inside the button which holds the Model attribute of CartCount.

naz786
  • 485
  • 1
  • 5
  • 22

2 Answers2

1
    <button class="cart-icon fr btn btn-info" type="button"        
onclick="location.href='<%: Url.Action("Action", "Controller") %>'">
       Cart <span class="badge cart-count">@Model.CartCount</span>
       </button>
maximelian1986
  • 2,308
  • 1
  • 18
  • 32
0

This solve it:

    <a href="@Url.Action("Index", "ShoppingCart", "")" class="cart-icon fr btn btn-info" type="button">
          Cart <span class="badge cart-count">@Model.CartCount</span>
    </a>
naz786
  • 485
  • 1
  • 5
  • 22