2

what is the correct way to use bootstrap button with thw Url. Action.

 @Url.Action("Delete", "Delete", null, new { id = item.Id }),new { @class = "btn btn-success btn-xs" })

Thanks

4
  • What's the problem with this code ? Commented Apr 12, 2017 at 12:45
  • if there is a problem with this code, probably is reference the to bootstrap.css Commented Apr 12, 2017 at 12:50
  • it shows that argument 5 : cannot convert from <anonymous type of= id to system web MVC ajax option Commented Apr 12, 2017 at 12:53
  • I answer your question...you're probably using the wrong helper Commented Apr 12, 2017 at 13:12

1 Answer 1

6

Actually I think you're using the wrong helper. What you want probably is ActionLink

@Html.ActionLink("Delete", "your action", "your controller", new { id = item.Id },new { @class = "btn btn-success btn-xs" })

if you still want to use Url.Action, just use like this

<a href="@Url.Action("your action", "your controller", new { id = item.Id }" class="btn btn-success btn-xs">Delete</a>
Sign up to request clarification or add additional context in comments.

1 Comment

@ElmerDantas in your ActionLink sample, the parenthesis before the last new keyword is wrong and must be removed in order to make the code work.

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.