Note that there are some explanatory texts on larger screens.

plurals
  1. POFiring events in UserControls (ASP.NET) - the event object is null?
    primarykey
    data
    text
    <p>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:</p> <ul> <li><a href="https://stackoverflow.com/questions/1039440/asp-net-send-an-objects-event-from-a-usercontrol-to-its-parent">asp.net: send an object&#39;s event from a UserControl to its Parent</a><br></li> <li><a href="http://objectmix.com/csharp/120067-event-object-null-when-event-fired-webusercontrol-asp-net-ajax.html" rel="nofollow noreferrer">http://objectmix.com/csharp/120067-event-object-null-when-event-fired-webusercontrol-asp-net-ajax.html</a></li> </ul> <p>However, I have tried according to what is recommended in those post, but the event object is null. Here is the code:</p> <p>In my Page who is to listen to the Event:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { fieldCustomer1.CustomerSelected += new UserControls.Field_Customer.uintDelegate(fieldCustomer1_CustomerSelected); } } </code></pre> <p>The Page_Load above is executed well before the EVent is fired (below).</p> <p>The code in the UserControl containing the Event:</p> <pre><code>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); } } </code></pre> <p>Is it ViewState or something like that, that I am missing? Why is CustomerSelected always null?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload