Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4621796
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:45:11+00:00 2026-05-22T02:45:11+00:00

I have a problem with the Event object being null when I want to

  • 0

I have a problem with the Event object being null when I want to fire the event. There are other threads here and on the net about this:

  • asp.net: send an object's event from a UserControl to its Parent
  • http://objectmix.com/csharp/120067-event-object-null-when-event-fired-webusercontrol-asp-net-ajax.html

However, I have tried according to what is recommended in those post, but the event object is null. Here is the code:

In my Page who is to listen to the Event:

protected void Page_Load(object sender, EventArgs e)
{
     if (!IsPostBack)
     {
          fieldCustomer1.CustomerSelected += new UserControls.Field_Customer.uintDelegate(fieldCustomer1_CustomerSelected);
     }
}

The Page_Load above is executed well before the EVent is fired (below).

The code in the UserControl containing the Event:

public partial class Field_Customer : System.Web.UI.UserControl
{
        public delegate void uintDelegate(uint id);
        public event uintDelegate CustomerSelected;

        // ... yada yada yada code code code

        [DirectMethod]  // ext.net stuff
        public void FireCustomerSelected()
        {
            if (CustomerSelected != null) // the CustomerSelected is always null
                CustomerSelected(_CustomerId);
        }
}

Is it ViewState or something like that, that I am missing? Why is CustomerSelected always null?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:45:12+00:00Added an answer on May 22, 2026 at 2:45 am

    Your eventhandler should be subscribed in every page load and not just the !postback

    protected void Page_Load(object sender, EventArgs e)
    {
    
              fieldCustomer1.CustomerSelected += new UserControls.Field_Customer.uintDelegate(fieldCustomer1_CustomerSelected);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem when assigning functions to the click event of a button
I have a problem; I'm using an external library where one particular event has
I have a strange problem where an onclick event on an input image is
I have an intermittent problem with some code that writes to a Windows Event
i have a problem using the Catch Clipboard Events code found on this link
I have a problem of web pages being cached even though I specify that
I have an Action Method that returns a JSON-serialized object. The problem I'm having
I have a base usercontrol in my ASP.Net app, There are HTML markup within
I have this strange, yet maybe very simple problem.. I have a timer1 in
I have a problem where a method is getting an undefined variable error, even

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.