473,473 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

User Control Events....

Hi all,
i do have a user control with 4 buttons, and all the events
are firing properly,

My problem is that i need to right an event handler in the user
control, which gets fired after a specific process is done,, but the
form which will host the user control has to specify what has to be
done

Something like this , if the event is fired it should call the event in
the page which is hosted

Help me out

Thanks in Advance

thomson

Nov 19 '05 #1
4 1729
Create a public event on the usercontrol that can be wired up to from the
page. So in your click event in the usercontrol you raise the event.
Nov 19 '05 #2
Hi thomson,

Actually, you don't want to write an event handler in the User Control. You
want to raise an event in the User Control, which can be handled by an event
handler in the form hosting it, if I understand you correctly. To make sure
that I DO understand you correctly, let me restate your problem, and let me
know if my interpretation is correct.

You have a User Control, which is similar to a Page in that it is a Control
that hosts other Controls. You mention that these hosted Controls, 4
buttons, fire events which are handled by the User Control hosting them. So
far, so good. Right? Okay, now don't forget that I mentioned that the Page
which hosts the User Control is similar in this respect to the User Control
itself, in that any Control can host other Controls that raise events, and
subscribe to the events with event handler methods.

So, what you want to do is to have the User Control, like a Button Control,
RAISE an event when it finishes a process of some kind, that the Page which
hosts that Control can respond to with its own event HANDLER method.

Did I get the problem right? I think it would help for you to fully
understand the following terms:

EventArgs - A class from which EventArgs classes are derived via
inheritance. EventArgs classes may or may not contain data (information)
about the class which raised the Event, or about the process in which the
Event was raised.

Delegate - A "template" for an Event Handler method, specifically for a
certain EventArgs type (class). A Delegate is similar to a "stubbed-out"
method, that is, a method that contains no process, but only a signature
(return type, name and parameters).

Raising an Event - a process that creates an EventArgs class, or a class
that inherits EventArgs, and broadcasts it to any subscribers to the Event.
Note that the broadcast itself is synchronous, that is, happening in a
sequence of instructions (process), but that the Event Handler method is
asynchronous, that is, happening in a separate thread from the current
execution thread in the class that responds to the Event.

Event Handler - a special method that has a signature matching a delegate
method for a specific type of EventArgs class. The Event Handler operates
asynchronously (in a spearate thread) from the current process being
executed by that class (the class that subscribes to the Event).

Subscribing to an Event - a process which "wires up" an EventHandler method
to an Event which may or may not be raised by another class.

Now, as to how to write the code, well, it differs in C# and VB.Net
(surprise, surprise). So, if you can tell me which language you're using, I
can give you some examples. If you're using VB.Net, this may account for
some of the confusion, as VB.Net can hide a lot of this, and allows you to
write simpler-LOOKING code to raise and handle events. Under the hood, of
course, both languages are doing the same thing, but it is actually easier
to see what is going on in C#, which is more strict about the code you
write.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
"thomson" <sa**********@yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi all,
i do have a user control with 4 buttons, and all the events
are firing properly,

My problem is that i need to right an event handler in the user
control, which gets fired after a specific process is done,, but the
form which will host the user control has to specify what has to be
done

Something like this , if the event is fired it should call the event in
the page which is hosted

Help me out

Thanks in Advance

thomson

Nov 19 '05 #3
UJ
Kevin,
I'm not the original poster but I'd be interested in how to do this in
VB.Net. I would like to do the same type of thing.

TIA - Jeffrey.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uc**************@TK2MSFTNGP15.phx.gbl...
Hi thomson,

Actually, you don't want to write an event handler in the User Control.
You want to raise an event in the User Control, which can be handled by an
event handler in the form hosting it, if I understand you correctly. To
make sure that I DO understand you correctly, let me restate your problem,
and let me know if my interpretation is correct.

You have a User Control, which is similar to a Page in that it is a
Control that hosts other Controls. You mention that these hosted Controls,
4 buttons, fire events which are handled by the User Control hosting them.
So far, so good. Right? Okay, now don't forget that I mentioned that the
Page which hosts the User Control is similar in this respect to the User
Control itself, in that any Control can host other Controls that raise
events, and subscribe to the events with event handler methods.

So, what you want to do is to have the User Control, like a Button
Control, RAISE an event when it finishes a process of some kind, that the
Page which hosts that Control can respond to with its own event HANDLER
method.

Did I get the problem right? I think it would help for you to fully
understand the following terms:

EventArgs - A class from which EventArgs classes are derived via
inheritance. EventArgs classes may or may not contain data (information)
about the class which raised the Event, or about the process in which the
Event was raised.

Delegate - A "template" for an Event Handler method, specifically for a
certain EventArgs type (class). A Delegate is similar to a "stubbed-out"
method, that is, a method that contains no process, but only a signature
(return type, name and parameters).

Raising an Event - a process that creates an EventArgs class, or a class
that inherits EventArgs, and broadcasts it to any subscribers to the
Event. Note that the broadcast itself is synchronous, that is, happening
in a sequence of instructions (process), but that the Event Handler method
is asynchronous, that is, happening in a separate thread from the current
execution thread in the class that responds to the Event.

Event Handler - a special method that has a signature matching a delegate
method for a specific type of EventArgs class. The Event Handler operates
asynchronously (in a spearate thread) from the current process being
executed by that class (the class that subscribes to the Event).

Subscribing to an Event - a process which "wires up" an EventHandler
method to an Event which may or may not be raised by another class.

Now, as to how to write the code, well, it differs in C# and VB.Net
(surprise, surprise). So, if you can tell me which language you're using,
I can give you some examples. If you're using VB.Net, this may account for
some of the confusion, as VB.Net can hide a lot of this, and allows you to
write simpler-LOOKING code to raise and handle events. Under the hood, of
course, both languages are doing the same thing, but it is actually easier
to see what is going on in C#, which is more strict about the code you
write.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.
"thomson" <sa**********@yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi all,
i do have a user control with 4 buttons, and all the events
are firing properly,

My problem is that i need to right an event handler in the user
control, which gets fired after a specific process is done,, but the
form which will host the user control has to specify what has to be
done

Something like this , if the event is fired it should call the event in
the page which is hosted

Help me out

Thanks in Advance

thomson


Nov 19 '05 #4
Hi Jeffrey,

Sorry to get back to you so late - serious deadline on top of me!

As I DO have a serious deadline, I hope you'll forgive me if I point you to
an excellent section of the online MSDN Library, which has a number of
articles and tutorials dealing with raising and consuming events in
VisualBasic.Net:

http://msdn.microsoft.com/library/de...singEvents.asp

Also, if anyone wants to read about this for C#:

http://msdn.microsoft.com/library/de...tsTutorial.asp

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"UJ" <fr**@nowhere.com> wrote in message
news:Ol**************@TK2MSFTNGP14.phx.gbl...
Kevin,
I'm not the original poster but I'd be interested in how to do this in
VB.Net. I would like to do the same type of thing.

TIA - Jeffrey.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uc**************@TK2MSFTNGP15.phx.gbl...
Hi thomson,

Actually, you don't want to write an event handler in the User Control.
You want to raise an event in the User Control, which can be handled by
an event handler in the form hosting it, if I understand you correctly.
To make sure that I DO understand you correctly, let me restate your
problem, and let me know if my interpretation is correct.

You have a User Control, which is similar to a Page in that it is a
Control that hosts other Controls. You mention that these hosted
Controls, 4 buttons, fire events which are handled by the User Control
hosting them. So far, so good. Right? Okay, now don't forget that I
mentioned that the Page which hosts the User Control is similar in this
respect to the User Control itself, in that any Control can host other
Controls that raise events, and subscribe to the events with event
handler methods.

So, what you want to do is to have the User Control, like a Button
Control, RAISE an event when it finishes a process of some kind, that the
Page which hosts that Control can respond to with its own event HANDLER
method.

Did I get the problem right? I think it would help for you to fully
understand the following terms:

EventArgs - A class from which EventArgs classes are derived via
inheritance. EventArgs classes may or may not contain data (information)
about the class which raised the Event, or about the process in which the
Event was raised.

Delegate - A "template" for an Event Handler method, specifically for a
certain EventArgs type (class). A Delegate is similar to a "stubbed-out"
method, that is, a method that contains no process, but only a signature
(return type, name and parameters).

Raising an Event - a process that creates an EventArgs class, or a class
that inherits EventArgs, and broadcasts it to any subscribers to the
Event. Note that the broadcast itself is synchronous, that is, happening
in a sequence of instructions (process), but that the Event Handler
method is asynchronous, that is, happening in a separate thread from the
current execution thread in the class that responds to the Event.

Event Handler - a special method that has a signature matching a delegate
method for a specific type of EventArgs class. The Event Handler operates
asynchronously (in a spearate thread) from the current process being
executed by that class (the class that subscribes to the Event).

Subscribing to an Event - a process which "wires up" an EventHandler
method to an Event which may or may not be raised by another class.

Now, as to how to write the code, well, it differs in C# and VB.Net
(surprise, surprise). So, if you can tell me which language you're using,
I can give you some examples. If you're using VB.Net, this may account
for some of the confusion, as VB.Net can hide a lot of this, and allows
you to write simpler-LOOKING code to raise and handle events. Under the
hood, of course, both languages are doing the same thing, but it is
actually easier to see what is going on in C#, which is more strict about
the code you write.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.
"thomson" <sa**********@yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi all,
i do have a user control with 4 buttons, and all the events
are firing properly,

My problem is that i need to right an event handler in the user
control, which gets fired after a specific process is done,, but the
form which will host the user control has to specify what has to be
done

Something like this , if the event is fired it should call the event in
the page which is hosted

Help me out

Thanks in Advance

thomson



Nov 19 '05 #5

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

Similar topics

1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
1
by: Earl Teigrob | last post by:
PROBLEM: When a user control is loaded into a PlaceHolder control more than once, the events do not fire on the first click of a control on the dynamically loaded user control. In other words, the...
5
by: George Durzi | last post by:
I have a simple user control with a text box and a submit button. When the user enters some text into the textbox and clicks the submit button, a record is created in the database. I'm using...
10
by: George G. | last post by:
Hi there, I am busy writing a new asp.net application and I am reusing some of my existing asp functions and methods in a user control. I need access to session, request and response in some of...
4
by: louise raisbeck | last post by:
Resending this as own topic as didnt get answer from original. Would be grateful for a response from anyone that knows. Thanks. Hi there, I found your post really helpful..but i wondered if, once...
6
by: Art | last post by:
Hi I'm new at this and need some help. I have a "solution" with 2 projects - the main project and a library. The library is simple, it contains a text box that will appear many times in the form...
1
by: Israel | last post by:
The problem: I want to know, definitively when a slider loses focus after a user has started sliding and hasn't released the mouse yet. It appears that this is captured with the WM_ACTIVATEAPP...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
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...
1
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...
0
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...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.