get submit button id

后端 未结 7 772
抹茶落季
抹茶落季 2021-01-21 02:57

Inside asp.net form I have few dynamically generated buttons, all of this buttons submit a form, is there a way to get which button was submit the form in page load event?

7条回答
  •  梦谈多话
    2021-01-21 03:32

    This won't work if your code is inside a user control:

    Request.Form.AllKeys.Contains("btnSave") ...
    

    Instead you can try this:

    if (Request.Form.AllKeys.Where(p => p.Contains("btnSave")).Count() > 0)
    {
        // btnSave was clicked, your logic here
    }
    

提交回复
热议问题