当我单击表单上的按钮时...我的代码永远不会到达它的 onclick 事件

发布于 2024-07-19 15:55:00 字数 114 浏览 16 评论 0原文

我有一个下拉列表和一个带有表单上按钮的文本框。 单击按钮时,即使在代码中,它也不会转到我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

戏剧牡丹亭 2024-07-26 15:55:00

我不是 VB.net 人员,但尝试将您的 asp:button 更改为:

 <asp:Button id="btnlookup" Height="24px" Text="LookUp" Width="60px" 
 OnClick="btnlookup_Click" runat="server"/>

I'm not a VB.net person but try changing your asp:button to this:

 <asp:Button id="btnlookup" Height="24px" Text="LookUp" Width="60px" 
 OnClick="btnlookup_Click" runat="server"/>
喜爱皱眉﹌ 2024-07-26 15:55:00

除了检查回发之外,您的 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?

夜光 2024-07-26 15:55:00

确保事件处理程序正在处理正确的控件,或者按钮标记在其 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.

萌无敌 2024-07-26 15:55:00

如果您的下拉列表未设置为自动回发,并且您在单击按钮(并触发回发)之前更改了其值,则应该触发下拉列表的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文