473,387 Members | 1,798 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,387 software developers and data experts.

Custom Event Handling within UserControl

I am trying to kick off an custom event in a usercontrol that the webpage
will listen and preform some actions if the event is fired from within my
usercontrol
Jul 21 '05 #1
2 1276
First you need to create a delegate. Do this outside the class:

public delegate void MyCustomEventHandler(object sender, MyCustomEventArgs e);

The above is an example of a delegate that you can define.

In side the class you then do the following:

public class MyClass
{
public event MyCustomEventHandler MyEvent;
.....
}

To fire the event you can do this:

if (MyEvent != null)
MyEvent(sender, args);

----
Alex Korchemniy

"Nicole - ASP/C# Beginner" wrote:
I am trying to kick off an custom event in a usercontrol that the webpage
will listen and preform some actions if the event is fired from within my
usercontrol

Jul 21 '05 #2
What would MyCustomEventArgs represent. Can I define it as something.

"Alex Korchemniy" wrote:
First you need to create a delegate. Do this outside the class:

public delegate void MyCustomEventHandler(object sender, MyCustomEventArgs e);

The above is an example of a delegate that you can define.

In side the class you then do the following:

public class MyClass
{
public event MyCustomEventHandler MyEvent;
....
}

To fire the event you can do this:

if (MyEvent != null)
MyEvent(sender, args);

----
Alex Korchemniy

"Nicole - ASP/C# Beginner" wrote:
I am trying to kick off an custom event in a usercontrol that the webpage
will listen and preform some actions if the event is fired from within my
usercontrol

Jul 21 '05 #3

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

Similar topics

1
by: jralford | last post by:
Hi, Another question from a C# newbie: I have a usercontrol class that includes a customized control. Now, if I create an instance of the class, and click on it, a click event is raised for the...
2
by: Phill. W | last post by:
How do I propagate an Event that I've just handled? I have a UserControl containing, among other things, a TextBox. The UserControl handles KeyDown/KeyPress Events for both itself and the...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
2
by: Nicole - ASP/C# Beginner | last post by:
I am trying to kick off an custom event in a usercontrol that the webpage will listen and preform some actions if the event is fired from within my usercontrol
2
by: Developer_Software | last post by:
Thanks in advance to anyone who can help :) I've got a placeholder control WITHIN A USER CONTROL that has its contents dynamically added and removed at runtime by a regular .aspx page. At...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
3
by: Zabto | last post by:
I created an array of 8X5 boxes to represents pixels in a character. Each box is a custom UserControl of a fixed size which is filled black if it's activated, or white if it's not. I wanted to...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
6
by: tshad | last post by:
I was looking at a page that showed how to set up a custom event and it seems to work ok. But I am not sure how I would use it. How would I subscribe to it. There is actual action (such as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.