473,662 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Event Handling c#


Hi,

I am currently learning c# so be gentle :)

I am converting a Delphi.NET website to c# website and I am confused as
to how events are handled.

2 Situations.

1. A component on a webusercontrol fires a postback event. On postback
the parent page handles that event and runs code specifically for that
page. So that the same event can run different code depending on what
page it is on.

2. A component on a webusercontrol fires a postback event and another
webusercontrol on that page recognises that event was fired and runs
its own method.
I hope this is enough information because I only know how it works in
Delphi.

Many Thanks
Jeremy
Feb 7 '07 #1
1 5351
Hi there,

You can handle an event only if you subscribed to it. Technically,
subscribing/handling means passing a method pointer to the event source:

Page.Load += new EventHandler(th is.Page_Load);

If you have programmed in C or C++ is similar to this

void* (*EventHandler) (object* source, EventArgs* e);
this.Load = &this.Page_Load ;

or if you programmed in Delphi Object Pascal it is equivalent to:

Page.Load := self.Page_Load;

I used similar because .NET events employ multicast delegates that are
‘collectionsâ €™ of method pointer so many subscribers can handle one event.
Anyway
>1. A component on a webusercontrol fires a postback event. On >postback the parent page handles that event and runs code >specifically for that page. So that the same event can run different >code depending on what page it is on.
Yes. Behind the scenes there’s always a statement that attaches event
handler to particular event. In ASP.NET 1.1, everything was explicitly
assigned in InitializeCompo nent() method. ASP.NET 2.0 (by default),
implicitly attaches event handlers for you based on naming convention and
AutoEventWireup @page attribute. For example, AutoEventWireup =true and page
compiler discovers there is a protected/public method called Page_Load(objec t
sender, EventArgs e), it automatically does assignment
Page.Load += new EventHandler(th is.Page_Load);
>2. A component on a webusercontrol fires a postback event and >another webusercontrol on that page recognises that event was fired >and runs its own method.
It doesn’t recognize, it just attaches an event handler as stated above.

Hope it’s clear now

Milosz

"Jeremy Martin" wrote:
>
Hi,

I am currently learning c# so be gentle :)

I am converting a Delphi.NET website to c# website and I am confused as
to how events are handled.

2 Situations.

1. A component on a webusercontrol fires a postback event. On postback
the parent page handles that event and runs code specifically for that
page. So that the same event can run different code depending on what
page it is on.

2. A component on a webusercontrol fires a postback event and another
webusercontrol on that page recognises that event was fired and runs
its own method.
I hope this is enough information because I only know how it works in
Delphi.

Many Thanks
Jeremy
Feb 7 '07 #2

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

Similar topics

8
2826
by: DylanM | last post by:
I have some checkboxes that are generated from the results of a database search. At the moment, the checkboxes are part of a table making up a form. Users are going through the form, clicking the boxes and saving to the database at the end with the 'Submit' command button. Is it possible to save the changes as the checkboxes are clicked? I suppose I'd need to write some dynamic ASP event handling at the same time as creating the checkboxes......
1
20691
by: Covad | last post by:
Hi all, For some reason my change() function is only called when the page loads. I'd much rather it gets called when the select changes. Here's the code: window.onload = init; function init() {
1
7565
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
6
1794
by: Steve Caliendo | last post by:
Hi, I'm creating 5 ImageButton controls in the panel control, and I have a unique ID specified for each one. When I click on any one of them, the Page_Load executes (Of course), but how do I know which ImageButton caused the post back ? Does it get handled in the Page_Load or do I need to create a new event handler ? Thanks,
3
3973
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which step you're on. This all works fine, but I ran into some trouble when I started creating controls dynamically in my code-behind file. Each panel contains a table which is filled with various radio buttons, text fields and the such which are...
2
3829
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 runtime, the placeholder control adds a dropdownlist where I would like it to redirect the user to a different page dependent on the selection they make from the dropdownlist. I've tried writing the delegate and the event handler both in the
7
2905
by: Christopher Pisz | last post by:
My problem is my derived class is getting called twice instead of the base and then the derived. I thought this was the purpose for virtuals and dynamic casting :/ I want my base class to have its method called and then the derived class have its method called. What am I not understanding? Int the following code, my Event Tester class is getting called twice for keyboard events when I step through the debugger:...
0
1342
by: =?Utf-8?B?SWRlcm9ja3M=?= | last post by:
Hi All, I created a dynamic checkbox in ASP .Net inside a Button1_Click event method (outside the page_load event) and performed the event handling method for the CheckedChanged event and I check the checkbox at runtime nothing happens (checkBoxObj.check is always false). Does anyone have information on how to make this work? Note: I can get it to work inside Page_Load event. I need help in getting it to work in different event...
1
6013
by: iderocks | last post by:
Hi All, I created a dynamic checkbox in ASP .Net inside a Button1_Click event method (outside the page_load event) and performed the event handling method for the CheckedChanged event and when I check the checkbox at runtime nothing happens (checkBoxObj.check is always false). Does anyone have information on how to make this work? Note: I can get it to work inside Page_Load event. I need help in getting it to work in a different event...
0
8344
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
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...
1
8546
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
7367
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
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
5654
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
4180
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
2762
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
1752
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.