user354427
user354427

Reputation: 385

ASP.NET Adding OnClick event to asp:DropDownList control

I need to add the OnClick event to asp:DropDownList control, due to the existing events don't satisfy my current needs.

Is it possible to achieve this?

Thank you very much.

Upvotes: 0

Views: 5322

Answers (1)

djdd87
djdd87

Reputation: 68476

What reason do you have for wanting an OnClick event on the DropDownList control? If you were to implement an OnClick server-side event on the DropDownList the user would never be able to select any of the list items. This is because in order to fire a Server-Side OnClick, a postback would be required. I.e. the user would click the DropDownList, a postback would instantly occur and they wouldn't be able to select a value.

It sounds like a case of trying to fix the wrong problem, however you could probably try and use the "onclick" JavaScript attribute and handle whatever you're trying to do using client side script and AJAX?

Upvotes: 2

Related Questions