473,378 Members | 1,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Raising Event not working

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;
}
}
Aug 26 '06 #1
7 1300

Tina wrote:
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;
}
}
I don't see you subscribing to the event anywhere. In the client you
need to say something like:

myEditGrid.RaiseCFEvent += new
ChangedFieldsEventHandler(myEditGrid_RaiseCFEvent) ;

Aug 27 '06 #2
Tina,

In addition to what Bruce wrote, you'll need to raise the event using
this:
RaiseCFEvent(myArgs);

instead of

this.OnRaiseCFEvent(myArgs);

kind regards,
Greg
Tina wrote:
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;
}
}
Aug 27 '06 #3
Maybe I'm overtired, but it appears to me that this won't be a problem,
because OnRaiseCFEvent in turn calls RaiseCFEvent.

Greg Cadmes wrote:
Tina,

In addition to what Bruce wrote, you'll need to raise the event using
this:
RaiseCFEvent(myArgs);

instead of

this.OnRaiseCFEvent(myArgs);

kind regards,
Greg
Tina wrote:
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;
}
}
Aug 27 '06 #4
It sounds just like you expect C# to auto wire-up (like VB); you just
need to subscribe to the event with

instance.RaiseCFEvent += {handler method};

Marc

Aug 27 '06 #5
I'm doing that. Please see my repost.
Thanks for responding.
T
"Bruce Wood" <br*******@canada.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
>
Tina wrote:
>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;
}
}

I don't see you subscribing to the event anywhere. In the client you
need to say something like:

myEditGrid.RaiseCFEvent += new
ChangedFieldsEventHandler(myEditGrid_RaiseCFEvent) ;

Aug 27 '06 #6
I'm doing that. Please see my repost.
Thanks for responding.
T
"Marc Gravell" <ma**********@gmail.comwrote in message
news:11********************@p79g2000cwp.googlegrou ps.com...
It sounds just like you expect C# to auto wire-up (like VB); you just
need to subscribe to the event with

instance.RaiseCFEvent += {handler method};

Marc

Aug 27 '06 #7
I see no repost. Please post it again.

Tina wrote:
I'm doing that. Please see my repost.
Thanks for responding.
T
"Bruce Wood" <br*******@canada.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...

Tina wrote:
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;
}
}
I don't see you subscribing to the event anywhere. In the client you
need to say something like:

myEditGrid.RaiseCFEvent += new
ChangedFieldsEventHandler(myEditGrid_RaiseCFEvent) ;
Aug 27 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: The Mess | last post by:
I am working in VB5. How do you mimmick Visual Basic's putting an Index argument at the front of the variables passed to an event when making your own control? This sounds kind of confusing so...
1
by: Rajesh.V | last post by:
I have made a custom control in asp.net using webcontrols, and am raising my event. I find that if no control is hooked into the event it goes for a toss. I tried to find length of the delegate...
6
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
4
by: rawCoder | last post by:
Hi all, How Can You Raise Events Asynchronously ? Now for the details ... I want to do inter modular communication using events in such a way that the contributing modules need not...
0
by: Joe Campbell | last post by:
I am encountering a problem raising WMI events from an asp.net application. The error received (as captured in the event log) is as follows: System.Runtime.InteropServices.COMException...
4
by: Dave A | last post by:
I am developing a somewhat complex component at the moment and coincidently I am also reading the Framework Design Guidelines book. After reading the section about event raising I have re-written...
2
by: Gman | last post by:
Hi, I have created a usercontrol, a grid control essentially. Within it I have a class: clsGridRecord. I have coded the events such that when a user clicks on the grid, say, the events occur on...
4
by: sloan | last post by:
I"m trying to figure out what concept I'm missing here, or if its not a good idea .. or what. Here is my example.. code is below. I have an employee class. It has an event that can be raised....
2
by: =?Utf-8?B?Um9i?= | last post by:
I'm new to event processing in vs 2005 - what I'm trying to achieve is broadly a network simulation of two workstations sending packets to each other . I have defined a class 'Workstation' and I...
7
by: Christian Cambier | last post by:
Hi, I have a textbox in a web user control. I then add the usercontrol to a web form. I also add a label in the web form. Now, when I press a key in the textbox, i want to display some text...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.