Using an event handler between and c#

Posted on 2011-10-11
Last Modified: 2012-05-12
We have a web page that uses code behind.  We have a user control that is written with c# code behind.

From the page we push a button that causes a modalpopup (ajax) to come to the screen.  The modalpopup displays our C# user control.  On this user control, the user enters some data and clicks search, and then this User Control needs to populate a grid view with some data.  Then the user will select something from the grid view and then data will go into a session variable that the page will use.  

Now, when we click the search button to do step 1 above, it calls back and does some server side processing and the modal pop up closes.  We want to show the modal pop up again and this is where the problem lies.

We have an event in the user control.  We are trying to call this event from the page.  When trying to code that we cannot access that event from the code.  

//Here is the event on the user control -
public event EventHandler UserControlButtonClicked;

'Then in we are trying to do this:
OrderSelector1. 'but there is no event name in there. please see screen shot.

Open in new window

Question by:Bran-Damage
    LVL 83

    Accepted Solution

    You need to use the AddHandler statement

    AddHandler OrderSelector1.UserControlButtonClicked, Addressof yoursub

    Author Closing Comment

    Perfect thanks.
    LVL 83

    Expert Comment

    Glad to help :-)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now