hi Tina
at a guess, your code goes something like this:
if(RaiseCFEVent != null)
this.RaiseCFEvent(args);
and you are wondering why the RaiseCFEVent delegate is null? if this is
null, it means nobody is listening for the event.
if you want some code to listen to the event, use code like this:
MyObject.RaiseCFEvent += new EventHandler(this.RaiseCFEvent_Handler);
where MyObject is the object that contains the event delegate. it may help
to open up the debugger in VS and examine the RaiseCFEvent delegate before
and after you add your event handlers, you will be able to see if any
handlers are wired up to it.
hope this helps.
tim
--
------------------------------------------
blog:
http://tim.mackey.ie
"Tina" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am trying to raise a custom event in a user control passing custom data
>arguments. I have done this many times in VB but this is my first time in
>C#.
>
> The code below passes the proper arguments in the
> this.OnRaiseCFEvent(myArgs); code but in the OnRaiseCFEvent method
> RaiseCFEVent is always null so this.RaiseCFEvent(this,e); never executes.
>
> Can anyone tell my why RaiseCFEvent is always null?
> thanks,
> T
>
>
>
>
> public partial class EditGrid : System.Web.UI.UserControl
> {
> public delegate void ChangedFieldsEventHandler(object sender,
> ChangedFieldsEventArgs e);
> public event ChangedFieldsEventHandler RaiseCFEvent;
> protected virtual void OnRaiseCFEvent(ChangedFieldsEventArgs e)
> {
> if (this.RaiseCFEvent != null)
> {
> this.RaiseCFEvent(this,e);
> }
> }
> .
> .
> .
> ChangedFieldsEventArgs myArgs = new
> ChangedFieldsEventArgs(gvRow.RowIndex, i, string1, string2);
> this.OnRaiseCFEvent(myArgs);
>
> .
> .
> .
>
>
>
> }
>
> public class ChangedFieldsEventArgs : EventArgs
> {
> public readonly int row, col;
> public readonly string newVal, oldVal;
> public ChangedFieldsEventArgs(int row, int col, string newVal, string
> oldVal)
> {
> this.row = row;
> this.col = col;
> this.newVal = newVal;
> this.oldVal = oldVal;
> }
> }
>