Object reference not set to an instance of an object

Ruslan's ASP .NET weblog

your own custom event delegate

in MyControl:

public delegate void MyEventHandler(int value, string text);

public event MyEventHandler MyEvent;

 

protected void ddl_SelectedIndexChanged(object sender, EventArgs e)

{

      MyEvent(((
DropDownList)sender).SelectedIndex, ((DropDownList)sender).SelectedItem.Text);

}

 

in Parent:

this.MyControl.MyEvent += new AAL.FreedomWeb.Web.UI.UserControls.AircraftConfig.MyEventHandler(MyControl_MyEvent);

 

private void MyControl_MyEvent(int value, string text)

{

      throw new NotImplementedException();

}

Posted: Aug 07 2008, 04:15 PM by funky_rus | with 5 comment(s)
Filed under: , , ,

Comments

Eralp said:

hi everybody ,

I just wanted to add something to your code.. ,

you may check this event related a method or not like this ,

if (this.myEvent!=null)

{

  MyEvent(((DropDownList)sender).SelectedIndex, ((DropDownList)sender).SelectedItem.Text);

}

just in case ;)

# August 7, 2008 2:07 PM

Patrik Hägne said:

All event handlers should be voids with two parameters, the first being the sender of the event (typed as object) and the second being event arguments (typed as EventArgs or inherited class). Always use the typed event handler delegate EventHandler<T>, there's no reason to create a custom delegate for this ever.

# August 7, 2008 4:22 PM

Whitny Swingfield said:

It was certainly interesting for me to read the article. Thanx for it. I like such topics and everything connected to this matter. I would like to read more soon.        

Whitny  Swingfield      

<a href="rome-escort.info/">escorts girls roma</a>

# March 16, 2011 6:20 AM

Jenny Flouee said:

It was extremely interesting for me to read that blog. Thanx for it. I like such topics and everything connected to them. I definitely want to read a bit more on this blog soon.          

Jenny  Flouee          

<a href="milanescorts.com/">milano escort annuncio</a>

# April 2, 2011 2:40 AM

Katty Watcerson said:

It is extremely interesting for me to read this article. Thanks for it. I like such topics and everything that is connected to this matter. I definitely want to read a bit more soon.            

Katty  Watcerson            

<a href="monacoescort.com/">independent ladies escort in monaco</a>

# April 26, 2011 2:17 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)