Adding OnClick event to ASP.NET control

前端 未结 3 2113
温柔的废话
温柔的废话 2021-01-15 08:06

i would like to create OnClick event for my panel. So far now the most of the google results look more or less like this: adding onclick event to a

3条回答
  •  情书的邮戳
    2021-01-15 08:16

    There is a PostBackUrl property on a ASP.NET Button, you could render the button as normal then postback to a different page - this is where your OnClick method would need to be declared.

    I would strongly recommend against posting back to the same page then doing a Response.Redirect(), consider the traffic. The browser requests the page, posts back then is sent a HttpRedirect and then navigates to the new page. With the method I have outlined above this is not required and the browser has to make one request less (meaning the message doesn't have to be sent or the page rebuilt on the server) and is a significant performance benefit.

提交回复
热议问题