Button.click事件和button.command事件有什么区别?

发布于 2024-09-25 04:06:31 字数 315 浏览 0 评论 0原文

Whats the difference between Button.Click Event and Button.Command Event in asp.net?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

倾其所爱 2024-10-02 04:06:31

正如文档所暗示的,Button.Command 事件允许您指定一个“命令”,以便您可以区分单击了哪个按钮等。

As the documentation implies,the Button.Command event allows you to specify a "command" so that you can differentiate between which button was clicked,etc.

独木成林 2024-10-02 04:06:31

按钮单击和命令的行为方式相同。两者都会执行 PostBack 操作,差别很小。

  1. 如果按钮同时关联了 Click 和 Command 事件,则先执行 Click eventHandler,然后执行 commandHandler。

  2. Click 事件不会发送任何参数,而 Command 会将 CommandName 和 CommandAgument 等参数发送到 codeBehind 代码。因此,这可以帮助开发人员在有多个按钮时找到触发哪个按钮。

Button Click and Command behaves with the same way. Both will perform PostBack operation and has small difference.

  1. If a button has both Click and Command events associated with it, then Click eventHandler is performed first, then commandHandler is performed.

  2. Click event does not send any parameters whereas Command will send parameters like CommandName and CommandAgrument to codeBehind code. So, this helps developers to find which button is triggered when they have multiple buttons.

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