Why am I getting a null for the event handler in an asp.net user control?

I am trying to construct a user control in C# ASP.NET

On the user control there is a button
IndustryShowButton

All is working well except, when I click this button I get the event handler  IndustryShowButtonClicked is null

See the code attached

Thanks
Stuart
using System;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ZZ_Development_Controls_IndustryUserControl : UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DefineButtonClicks();
    }  

//Other Code………………………………………………………
  
  
    protected void DefineButtonClicks()
    {
        IndustryShowButton.Click += new System.EventHandler(this.IndustryShowButton_OnClick);
    }

    public event IndustryControlEventHandler IndustryShowButtonClicked;


    // On show button click create object and fire  
    protected void IndustryShowButton_OnClick(object sender, EventArgs e)
    {
        bool showButtonClicked = true;
        IndustryControlEventArgs args = new IndustryControlEventArgs(showButtonClicked);
        IndustryShowButtonClicked(this, args);
    }
}


public class IndustryControlEventArgs : EventArgs
{
    public IndustryControlEventArgs(bool item)
    {
        showHide = item;
    }
    
    private bool showHide;
    public bool ShowHide
    {
        get { return showHide; }
    }
}

public delegate void IndustryControlEventHandler(object sender, IndustryControlEventArgs e);

Open in new window

Stuart_LairdAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Attach the handler in the Init method:

protected override void OnInit(EventArgs e)
{
    DefineButtonClicks();
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Stuart_LairdAuthor Commented:
Thanks
0
Amandeep Singh BhullarCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.