Reputation: 52932
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
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
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