Disable buttons on post back using jquery in .net app

后端 未结 7 2080
悲哀的现实
悲哀的现实 2020-12-20 17:03

I have a asp.net app that I want to disable the buttons as soon as they are clicked in order to prevent multiple submissions. I\'d like to use jquery for this as the site a

7条回答
  •  孤城傲影
    2020-12-20 17:57

    The approach of disabling the button before the submit has two effects: -

    a) The button takes on the disabled appearance.

    b) The button's value is not posted in the form parameters.

    If the button's value is not being posted to the server, ASP.Net does not know which button was pressed and thus it does not run the relevent OnClick handler.

    To verify add the following to your code behind

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write("Load " + IsPostBack + "
    "); foreach (string s in Request.Form.AllKeys) { Response.Write(string.Format("s:'{0}' = {1}
    ", s, Request.Form[s])); } }

    And then run the page (both with J.S. to disable the buttons and without). If the button's value is not being posted to the server, ASP.Net does not know which button was pressed and thus it does not run the relevent OnClick handler.

提交回复
热议问题