I want to create a button which when clicked calls an action. I have used Html.ActionLink
to create a link which does exactly that but there is no Html.ActionButton
. Is there some other way?
Yes, there is a difference. Html. ActionLink generates an <a href=".."></a> tag whereas Url. Action returns only an url.
ActionLink creates a hyperlink on a view page and the user clicks it to navigate to a new URL. It does not link to a view directly, rather it links to a controller's action.
You'll have to serialize your model as a JSON string, and send that to your controller to turn into an object. Please don't format with snippets when the language used is not displayable by them. It doesn't improve the answer and makes your answer more cluttered. Regular code blocks will work fine.
Here is an example using Bootstrap's CSS button and applying it against the link to make it look exactly like the button.
@Html.ActionLink("Select", "Select", new { id = patient.Id }, new { @class = "btn btn-primary", @style = "color:white" })
Is there some other way?
You could use a html <form>
:
@using (Html.BeginForm("someAction", "someController")) { <button type="submit">OK</button> }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With