title: Event Handler is Always null
body: <p>I have searched extensively on this, but cannot find the solution to my problem. I am trying to call a function in the code behind of a page from a user control on that page.</p>
  
  <p>I have a web application that uses a master page. I am adding a user control that I wrote to one of the content pages. I added the user control to the aspx page by dragging and dropping it from the toolbox. I am able to see the user control from the code behind, but I cannot access the public functions. To fix that problem, I created an object of the user control in the code behind and used the LoadControl function. All of that seems to work fine.</p>
  
  <p>The problem I am having is when I am trying to hook the into the EventHandler from the aspx page to the user control. Everything compiles and runs just fine, but I am not seeing anything happen on the page. I think the issue is that the EventHandler is always null.</p>
  
  <p>User Control Code</p>
  
  <pre><code>public partial class ucBuyerList : System.Web.UI.UserControl
  {
      public delegate void BuyerSelectedEventHandler(object sender, EventArgs e);
      public event BuyerSelectedEventHandler BuyerSelected;
  
      private string name = "";
      public string Name
      {
          get { return name; }
          set { name = value; }
      }
  
      private string auid = "";
      public string AUID
      {
          get { return auid; }
          set { auid = value; }
      }
  
      protected void Page_Load(object sender, EventArgs e)
      {
  
      }
  
      private void OnBuyerSelected(EventArgs e)
      {
          if (BuyerSelected != null)
          {
              BuyerSelected(this, new EventArgs());
          }
      }
  
      protected void lbBuyerList_SelectedIndexChanged(object sender, EventArgs e)
      {
          SetNameAndAUID();
          OnBuyerSelected(e);
      }
  
      private void SetNameAndAUID()
      {
          name = lbBuyerList.SelectedItem.Text;
          auid = lbBuyerList.SelectedItem.Value;
      }
  }
  </code></pre>
  
  <p>Parent Page Code</p>
  
  <pre><code>    public partial class frmBuyerInformation : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
          Master.changePageTitle("Buyer Information");
          buyerList.BuyerSelected += new ucBuyerList.BuyerSelectedEventHandler(buyerListControl_BuyerSelected);
      }
  
      void buyerListControl_BuyerSelected(object sender, EventArgs e)
      {
          DisplayBuyerInformation();
      }
  
      public void DisplayBuyerInformation()
      {
          tbName.Text = buyerList.Name;
          tbAUID.Text = buyerList.AUID;
      }
  }
  </code></pre>
  
  <p>Can anyone see what I am doing wrong?</p>
  
  <p>EDIT: This issue has been resolved. The code snippits above are now functional. If anyone runs into the issue I had, you can model the code above. Make sure that <code>AutoEventWireup="true"</code> in both the aspx and ascx pages. Thank you June Paik for your solution. Thank you Diego De Vita for your input as well.</p>