ASP.NET 将 OnClick 事件添加到 asp:DropDownList 控件
我需要将 OnClick 事件添加到 asp:DropDownList 控件,因为现有事件不能满足我当前的需求。
有可能实现这一目标吗?
非常感谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您希望在
DropDownList
控件上使用OnClick
事件的原因是什么?如果您要在DropDownList
上实现OnClick
服务器端事件,用户将永远无法选择任何列表项。这是因为为了触发服务器端 OnClick,需要回发。即,用户单击 DropDownList,将立即发生回发,并且他们将无法选择值。这听起来像是尝试修复错误问题的情况,但是您可能可以尝试使用“onclick”JavaScript 属性并使用客户端脚本和 AJAX 处理您尝试执行的任何操作?
What reason do you have for wanting an
OnClick
event on theDropDownList
control? If you were to implement anOnClick
server-side event on theDropDownList
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
?