473,573 Members | 2,833 Online
Bytes | Software Development & Data Engineering Community
+ 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 1744
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**********@y ahoo.com> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:uc******** ******@TK2MSFTN GP15.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**********@y ahoo.com> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.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.c om> wrote in message
news:Ol******** ******@TK2MSFTN GP14.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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:uc******** ******@TK2MSFTN GP15.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**********@y ahoo.com> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.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
7554
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 dropdown in UC1 _________________________ 1) MainPage_Load 2) User Control_1 Load
1
8143
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 first time the control is dynamically loaded, everything works fine. After that, if the control is loaded again from the page button event handler,...
5
9741
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 this user control inside another webform. The webform has a "Next" button which is initially disabled. When the user control successfully adds a record...
10
2484
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 the functions and I can't find out how to do it. Here is an example of what I do and I get the following Cannot refer to an instance member of a...
4
2500
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 I have exposed a public property containing the value of a textbox in a user control..how do I grab this from the calling page? I cant think of the...
6
1675
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 in the main project My problem is that I would like events (leaving the text box) to be recognized in the main project. Alternatively I would...
1
2276
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 message but this only goes to the form and I want it in the user control that maybe very much removed from the form's knowledge; i.e. the form may...
9
3176
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 load with different data (locations, departments, etc.).
2
4808
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 required: <%@ Register TagPrefix="UC" TagName="MyUserCtrl" Src="MyUC.ascx" %> Assuming that the ASPX page doesn't use a code-behind, I can access the...
0
7699
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
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...
1
7788
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...
0
8066
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...
0
6421
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5292
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...
1
2216
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
1
1304
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1041
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.