Cancel button in form

后端 未结 9 2402
借酒劲吻你
借酒劲吻你 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:36

    I ended up making a helper so I could reuse the cancel button. I added a js confirm in case people click the cancel button by accident after filling in the form.

    @helper FormCancelButton(string cancelUrl)
    {
        
    }
    

    I then call it like so:

    @FormCancelButton(Url.Action("Index", "User" ))
    

    If you are really keen you could try and detect the dirty state of the form too and only show the confirm dialog if the form had been changed.

提交回复
热议问题