Cancel button in form

后端 未结 9 2026
借酒劲吻你
借酒劲吻你 2021-02-05 14:28

I have a cancel button in a form:

@using (Html.BeginForm(\"ConfirmBid\",\"Auction\"))
        {
          some stuff ...

                    

        
相关标签:
9条回答
  • 2021-02-05 14:52
    <a href="@Url.Action("CancelBid", "Auction")"><img src="../../Content/css/img/btn-submit.png" class="btn-form" /></a>
    
    0 讨论(0)
  • 2021-02-05 14:54
    <a href="/Auction/[ActionName]">
        <input type="image" src="@Url.Content("~/Content/css/img/btn-cancel.png")" class="btn-form" />
    </a>
    

    if you want to preserve its look as a button, you could do something like this:

    <a href="/Auction/[ActionName]">
        <input type="button" value="Cancel">
    </a>
    

    where [ActionName] is the name of the action that will return your desired view.

    0 讨论(0)
  • 2021-02-05 14:57

    Or a styled submit button:

    <input type="submit" value="Save Form" name="Save" class="submit-button btn-form" /> 
    

    Then Javascript for cancel button:

    <input type="button" onclick="document.location.href('Home/Index')" value="Cancel" class="cancel-button btn-form" />
    // Note: This avoids any of the validation that may happen in the model that 
    // normally gets triggered with a submit
    
    0 讨论(0)
提交回复
热议问题