You can determine which control called PostBack by looking at Request.Form["__EVENTTARGET"] . The problem is that the ids buttons will not be displayed unless you set their UseSubmitBehavior to false . Here is an example:
.aspx.cs
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { switch (Request.Form["__EVENTTARGET"].ToString()) { case "ddlOne": break; case "btnOne": break; case "btnTwo": break; } } }
.aspx
<form id="form1" runat="server"> <asp:DropDownList ID="ddlOne" AutoPostBack="true" runat="server"> <asp:ListItem Text="One" Value="One" /> <asp:ListItem Text="Two" Value="Two" /> </asp:DropDownList> <asp:Button ID="btnOne" Text="One" UseSubmitBehavior="false" runat="server" /> <asp:Button ID="btnTwo" Text="Two" UseSubmitBehavior="false" runat="server" /> </form>
source share