473,804 Members | 3,031 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Raise Event not working (revised)

(my last post was incomplete so this issue is being reposted)

I have an ASP.Net C# app with a Default.aspx page with an ascx user control
on the page named EditGrid.ascx given the ID myEG on the page.
I am trying to raise a custom event in this user control passing custom data
arguments. I have done this many times in VB but this is my first time in
C#.

In the default.aspx page I have the following code to subscribe to the event
along with an empty method to handle the event:
protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack){

myEG.RaiseCFEve nt += new
EditGrid.Change dFieldsEventHan dler(this.Handl eChangedEvent); }

}
protected void HandleChangedEv ent(object sender, ChangedFieldsEv entArgs
e)
{
string myString = "debug";
}
The code below, in the ascx control, passes the proper arguments in the
this.OnRaiseCFE vent(myArgs); code but in the OnRaiseCFEvent method
RaiseCFEVent is always null so this.RaiseCFEve nt(this,e); never executes.

Can anyone tell my why RaiseCFEvent is always null? As you can see there is
a subscriber
to the event.
thanks,
T

public partial class EditGrid : System.Web.UI.U serControl
{
public delegate void ChangedFieldsEv entHandler(obje ct sender,
ChangedFieldsEv entArgs e);
public event ChangedFieldsEv entHandler RaiseCFEvent;
protected virtual void OnRaiseCFEvent( ChangedFieldsEv entArgs e)
{
if (this.RaiseCFEv ent != null)
{
this.RaiseCFEve nt(this,e);
}
}
..
..
..
ChangedFieldsEv entArgs myArgs = new
ChangedFieldsEv entArgs(gvRow.R owIndex, i, string1, string2);
this.OnRaiseCFE vent(myArgs);

..
..
..

}

public class ChangedFieldsEv entArgs : EventArgs
{
public readonly int row, col;
public readonly string newVal, oldVal;
public ChangedFieldsEv entArgs(int row, int col, string newVal, string
oldVal)
{
this.row = row;
this.col = col;
this.newVal = newVal;
this.oldVal = oldVal;
}
}
Aug 27 '06 #1
2 1527
Have you tried to put a breakpoint on this line...
myEG.RaiseCFEve nt += new
EditGrid.Change dFieldsEventHan dler(this.Handl eChangedEvent); }

and make sure the event is registered correctly.
Tina wrote:
(my last post was incomplete so this issue is being reposted)

I have an ASP.Net C# app with a Default.aspx page with an ascx user control
on the page named EditGrid.ascx given the ID myEG on the page.
I am trying to raise a custom event in this user control passing custom data
arguments. I have done this many times in VB but this is my first time in
C#.

In the default.aspx page I have the following code to subscribe to the event
along with an empty method to handle the event:
protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack){

myEG.RaiseCFEve nt += new
EditGrid.Change dFieldsEventHan dler(this.Handl eChangedEvent); }

}
protected void HandleChangedEv ent(object sender, ChangedFieldsEv entArgs
e)
{
string myString = "debug";
}
The code below, in the ascx control, passes the proper arguments in the
this.OnRaiseCFE vent(myArgs); code but in the OnRaiseCFEvent method
RaiseCFEVent is always null so this.RaiseCFEve nt(this,e); never executes.

Can anyone tell my why RaiseCFEvent is always null? As you can see there is
a subscriber
to the event.
thanks,
T

public partial class EditGrid : System.Web.UI.U serControl
{
public delegate void ChangedFieldsEv entHandler(obje ct sender,
ChangedFieldsEv entArgs e);
public event ChangedFieldsEv entHandler RaiseCFEvent;
protected virtual void OnRaiseCFEvent( ChangedFieldsEv entArgs e)
{
if (this.RaiseCFEv ent != null)
{
this.RaiseCFEve nt(this,e);
}
}
.
.
.
ChangedFieldsEv entArgs myArgs = new
ChangedFieldsEv entArgs(gvRow.R owIndex, i, string1, string2);
this.OnRaiseCFE vent(myArgs);

.
.
.

}

public class ChangedFieldsEv entArgs : EventArgs
{
public readonly int row, col;
public readonly string newVal, oldVal;
public ChangedFieldsEv entArgs(int row, int col, string newVal, string
oldVal)
{
this.row = row;
this.col = col;
this.newVal = newVal;
this.oldVal = oldVal;
}
}

Aug 27 '06 #2

I posted the answer to this question over here.

http://www.microsoft.com/communities...d-2ad40ac8085a

Thanks,
Sazid.

"john sun" wrote:
Have you tried to put a breakpoint on this line...
myEG.RaiseCFEve nt += new
EditGrid.Change dFieldsEventHan dler(this.Handl eChangedEvent); }

and make sure the event is registered correctly.
Tina wrote:
(my last post was incomplete so this issue is being reposted)

I have an ASP.Net C# app with a Default.aspx page with an ascx user control
on the page named EditGrid.ascx given the ID myEG on the page.
I am trying to raise a custom event in this user control passing custom data
arguments. I have done this many times in VB but this is my first time in
C#.

In the default.aspx page I have the following code to subscribe to the event
along with an empty method to handle the event:
protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack){

myEG.RaiseCFEve nt += new
EditGrid.Change dFieldsEventHan dler(this.Handl eChangedEvent); }

}
protected void HandleChangedEv ent(object sender, ChangedFieldsEv entArgs
e)
{
string myString = "debug";
}
The code below, in the ascx control, passes the proper arguments in the
this.OnRaiseCFE vent(myArgs); code but in the OnRaiseCFEvent method
RaiseCFEVent is always null so this.RaiseCFEve nt(this,e); never executes.

Can anyone tell my why RaiseCFEvent is always null? As you can see there is
a subscriber
to the event.
thanks,
T

public partial class EditGrid : System.Web.UI.U serControl
{
public delegate void ChangedFieldsEv entHandler(obje ct sender,
ChangedFieldsEv entArgs e);
public event ChangedFieldsEv entHandler RaiseCFEvent;
protected virtual void OnRaiseCFEvent( ChangedFieldsEv entArgs e)
{
if (this.RaiseCFEv ent != null)
{
this.RaiseCFEve nt(this,e);
}
}
.
.
.
ChangedFieldsEv entArgs myArgs = new
ChangedFieldsEv entArgs(gvRow.R owIndex, i, string1, string2);
this.OnRaiseCFE vent(myArgs);

.
.
.

}

public class ChangedFieldsEv entArgs : EventArgs
{
public readonly int row, col;
public readonly string newVal, oldVal;
public ChangedFieldsEv entArgs(int row, int col, string newVal, string
oldVal)
{
this.row = row;
this.col = col;
this.newVal = newVal;
this.oldVal = oldVal;
}
}
Aug 27 '06 #3

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

Similar topics

2
1599
by: (Pete Cresswell) | last post by:
I've been perusing a "real-life" application and notice that for instance, in a button's Click() event, they don't write the processing code. Instead, they raise an event like AddNewRecord and then put the coding that would have been in the click event in the AddNewRecord event handler. It seems TB throughout the app, so I'm guessing it's some sort of Best Practice. Anybody care to explain? -- PeteCresswell
1
1274
by: User | last post by:
Hi, How better is to implement my own event (and calling my raiseevent) instead of calling a function. I receive a lot of data via winsock control, should I raise my event when receiving all this data, and then parse this data. OR
1
10522
by: Dan Cimpoiesu | last post by:
I have a remoting object, derived from MarshalByRefComponent, that I instantiate on the client side, with Activator.GetObject. Can I receive events fired on the server, on the client? How?
5
3224
by: Waleed AlRashoud | last post by:
Hi, I hope u can help me I asked this question before but I didn't explain it very well. Let say I hvae a thread 'A', creates object 'O', and start thread 'B' to do some work on 'O', OK? I want thread 'B' to fire event of 'O' BUT MUST THAT EVENT DONE BY THREAD 'A' not 'B'!!
12
2947
by: Vittorio Pavesi | last post by:
Hello, is it possible to manually raise the event Elapsed of the timer object ? Vittorio
12
2934
by: Benny Raymond | last post by:
I understand that you would normally want to raise an event on the same thread so that your code blocks until the event has been dealt with... however i've run into a situation where I have a thread running that isn't my form thread and I want it to raise a custom event and continue going without waiting for that event to be handled... Is this at all possible?
3
2137
by: =?Utf-8?B?Ulc=?= | last post by:
I constructed a new Class with some private members. I would like an event to be raised on the moment the value of one of those private members is changed. How do I define an event for that private member and how do I raise the event? -- RW
5
2015
by: Mike | last post by:
Hi group; Let say I have an object called Account, that raises an event called AccountLow with its owns EventArgs, and when this event gets raised, I will like to raise another custom event called AccountGotLowAmount and passes AccountLow’s EventArgs along with the new event.
11
4034
by: nadeem_far | last post by:
Hello, I am working on a c# project using framework 1.1. Since its a console application,no windows forms are being used. I am trying to implement event driven classes that just want to raise the event and continue working( like fire and forget - do not wait for the event handler in client to finish.) I have gone through alot of the articles on internet and MSDN and most talk about delegates (or BackGroundWorker in 2.0 which I cannot
0
10571
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10326
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10317
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.