当我单击表单上的按钮时...我的代码永远不会到达它的 onclick 事件
我有一个下拉列表和一个带有表单上按钮的文本框。 单击按钮时,即使在代码中,它也不会转到我的 onclick ,但它会转到我的下拉列表的 selectedIndexchanged 事件。 我怎样才能解决这个问题?
I have a dropdownlist and a textbox with a button on a form. When a button is clicked it does not go to my onclick even in the code but it goes to my dropdownlist's selectedIndexchanged event. How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不是 VB.net 人员,但尝试将您的 asp:button 更改为:
I'm not a VB.net person but try changing your asp:button to this:
除了检查回发之外,您的 Page_Load 是否调用了更改所选索引或 DropDownList 中的项目?
Does your Page_Load have a call to changing the selected index or the items in the DropDownList outside of checking for postback?
确保事件处理程序正在处理正确的控件,或者按钮标记在其 onclick 元素上引用正确的方法。
Make sure the event handler is handling the correct control, or the button tag is referencing the correct method on it's onclick element.
如果您的下拉列表未设置为自动回发,并且您在单击按钮(并触发回发)之前更改了其值,则应该触发下拉列表的 onchange 事件。
...这并不是说这解释了为什么您的单击处理程序没有触发。
If your dropdown list is not set to autopostback, and you change its value before clicking the button (and triggering a postback), then the dropdown's onchange event is supposed to fire.
...not that this explains why you click handler isn't firing.