How do you create a plain old image button in MVC 4 (Razor)? I'm looking for something like this
The Image property of a Button control is used to set a button background as an image. The Image property needs an Image object. The Image class has a static method called FromFile that takes an image file name with full path and creates an Image object. You can also align image and text.
The image buttons in the HTML document can be created by using the type attribute of an <input> element. Image buttons also perform the same function as submit buttons, but the only difference between them is that you can keep the image of your choice as a button.
try this
@using (Html.BeginForm("ActionTaken", "TestController")) {
<button name="button" value="ActionOne" class="button" style="width: 200px;">
<img src=""/></button>
<button name="button" class="button" style="width: 160px;" value="ActionTwo">
<img src=""/></button> }
Add this to your razor view:
<input type="image" src="<image path here>" alt="Submit" width="48" height="48">
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