Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine which button caused postback

I have 2 button controls. When I click one i'm trying to determine which one caused a postback in the page load. How to do determine this?

like image 643
Will Avatar asked Apr 19 '12 14:04

Will


1 Answers

What about using CommandName and CommandArgument has shown in this example. This way you can have just one handler.

<asp:Button id="Button1"
       Text="Sort Ascending"
       CommandName="Sort"
       CommandArgument="Ascending"
       OnCommand="CommandBtn_Click" 
       runat="server"/>

  <asp:Button id="Button2"
       Text="Sort Descending"
       CommandName="Sort"
       CommandArgument="Descending"
       OnCommand="CommandBtn_Click" 
       runat="server"/>
like image 116
Kris Krause Avatar answered Oct 09 '22 08:10

Kris Krause