如何确定哪个触发器触发了我的更新面板?

发布于 2024-08-05 15:12:16 字数 919 浏览 1 评论 0原文

我有一个更新面板和触发它的按钮列表。我需要某种方法来找出当加载方法(由触发器引起)关闭时按下了哪个按钮,但我无法弄清楚。发送者不会投射到触发器中,而是投射到更新面板本身。

我需要根据按下的按钮执行一些操作。

有什么建议吗?

我正在使用 ASP.NET / C#

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" OnLoad="LocationList_Load">

<Triggers>
    <asp:AsyncPostBackTrigger ControlID="btnLocMiddleEast" />
    <asp:AsyncPostBackTrigger ControlID="btnLocUSA" />
    <asp:AsyncPostBackTrigger ControlID="btnLocNewZealand" />
    <asp:AsyncPostBackTrigger ControlID="btnLocAustralia" />
    <asp:AsyncPostBackTrigger ControlID="btnLocEurope" />
    <asp:AsyncPostBackTrigger ControlID="btnLocRepublicOfIreland" />
    <asp:AsyncPostBackTrigger ControlID="btnLocNorthernIreland" />
    <asp:AsyncPostBackTrigger ControlID="btnLocWales" />
    <asp:AsyncPostBackTrigger ControlID="btnLocScotland" />

I have an update panel and a list of buttons that trigger it. I need some way to find out which button was pressed when the load method (which is caused by the triggers) goes off, but I can't figure it out. Sender doesn't cast into the trigger, but the update panel itself.

I need to perform some action based on which button was pressed.

Any advice?

I'm using ASP.NET / C#

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" OnLoad="LocationList_Load">

<Triggers>
    <asp:AsyncPostBackTrigger ControlID="btnLocMiddleEast" />
    <asp:AsyncPostBackTrigger ControlID="btnLocUSA" />
    <asp:AsyncPostBackTrigger ControlID="btnLocNewZealand" />
    <asp:AsyncPostBackTrigger ControlID="btnLocAustralia" />
    <asp:AsyncPostBackTrigger ControlID="btnLocEurope" />
    <asp:AsyncPostBackTrigger ControlID="btnLocRepublicOfIreland" />
    <asp:AsyncPostBackTrigger ControlID="btnLocNorthernIreland" />
    <asp:AsyncPostBackTrigger ControlID="btnLocWales" />
    <asp:AsyncPostBackTrigger ControlID="btnLocScotland" />

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

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

发布评论

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

评论(3

九歌凝 2024-08-12 15:12:16

检查我对这个问题的回答:

制作嵌套更新面板中 AsyncPostback 之间的差异

基本上,您应该检查 ScriptManager.AsyncPostBackSourceElementID 用于触发器。

Check the answer I gave to this question:

Making a difference between AsyncPostbacks in nested update panels

Basically you should check the ScriptManager.AsyncPostBackSourceElementID for the trigger.

怪我太投入 2024-08-12 15:12:16

通常,我只会为每个按钮创建一个单独的 Click 事件处理程序,然后编写应在每个事件处理程序中触发的特定代码。

Normally I would just create an individual Click event handler for each button, and then write the specific code that should be triggered in each event handler.

万水千山粽是情ミ 2024-08-12 15:12:16

如果您正在调试,可以检查堆栈跟踪

If you're debugging, you can check the stack trace.

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