NibblyPig
NibblyPig

Reputation: 52932

How do I work out which trigger triggered my update panel?

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" />

Upvotes: 0

Views: 1373

Answers (3)

Zhaph - Ben Duguid
Zhaph - Ben Duguid

Reputation: 26956

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.

Upvotes: 1

Pete
Pete

Reputation: 12553

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.

Upvotes: 1

Neil Barnwell
Neil Barnwell

Reputation: 42125

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

Upvotes: 0

Related Questions