473,796 Members | 2,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

do you know how i to create events dynamicaly?

hello friends, i am writing a page aspx and creating controls dinamicaly and
then
i must to create for each control the events as well.

Anybody to know how?????

happy day

lion
Nov 16 '05 #1
3 1797
hi Lion
this should be fairly simple . the event that are associated with an
object are integrated along with them so what you need to do it .
" have the handler method ready beforehand ( even if you might not use
them , or you may have to use them with other controls )
" then when you create your control associate the appropriate handler with
the event of the control you just created
lets say for example that you are to create buttons on your page at run
time , and you want to handle the click event of these runtime buttons
first you need to have an handling method ( with the expected signature
from the handler)
lets say you declared such function as follows, this function would
change the display text of your clicked button to "clicked"
private void handle_clicks (object sender, System.EventArg s e)
{
Button k = (Button)sender ;
k.Text = " clicked " ;

}

Then, when you create you control ,associate the click event with that
hander in one assigning statement ( technically you will be creating a new
EventHandler delegate, passing the handle_clicks function to the delegate
constructor , and subscribing the delegate with the event )
Lets say you create button f at runtime as follows
Button f = new Button();
Then add the handler to its click event as follows
f.Click+= new System.EventHan dler(this. handle_clicks);
and anther button m
Button m = new Button();
m.Click+= new System.EventHan dler(this.handl e_clicks);
hope this was clear
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #2
yes, yes.

I have associate it for the handler and that's it.

Thank's a lot

leon.
"Mohamoss" <mo************ @egdsc.microsof t.com> wrote in message
news:t7******** ******@cpmsftng xa06.phx.gbl...
hi Lion
this should be fairly simple . the event that are associated with an
object are integrated along with them so what you need to do it .
" have the handler method ready beforehand ( even if you might not use
them , or you may have to use them with other controls )
" then when you create your control associate the appropriate handler with the event of the control you just created
lets say for example that you are to create buttons on your page at run
time , and you want to handle the click event of these runtime buttons
first you need to have an handling method ( with the expected signature
from the handler)
lets say you declared such function as follows, this function would
change the display text of your clicked button to "clicked"
private void handle_clicks (object sender, System.EventArg s e)
{
Button k = (Button)sender ;
k.Text = " clicked " ;

}

Then, when you create you control ,associate the click event with that
hander in one assigning statement ( technically you will be creating a new EventHandler delegate, passing the handle_clicks function to the delegate
constructor , and subscribing the delegate with the event )
Lets say you create button f at runtime as follows
Button f = new Button();
Then add the handler to its click event as follows
f.Click+= new System.EventHan dler(this. handle_clicks);
and anther button m
Button m = new Button();
m.Click+= new System.EventHan dler(this.handl e_clicks);
hope this was clear
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #3
Hey Mohamed, thanks a lot.
I have done you words and that's it, very easy man.

thanks.

lion.
"Mohamoss" <mo************ @egdsc.microsof t.com> wrote in message
news:t7******** ******@cpmsftng xa06.phx.gbl...
hi Lion
this should be fairly simple . the event that are associated with an
object are integrated along with them so what you need to do it .
" have the handler method ready beforehand ( even if you might not use
them , or you may have to use them with other controls )
" then when you create your control associate the appropriate handler with the event of the control you just created
lets say for example that you are to create buttons on your page at run
time , and you want to handle the click event of these runtime buttons
first you need to have an handling method ( with the expected signature
from the handler)
lets say you declared such function as follows, this function would
change the display text of your clicked button to "clicked"
private void handle_clicks (object sender, System.EventArg s e)
{
Button k = (Button)sender ;
k.Text = " clicked " ;

}

Then, when you create you control ,associate the click event with that
hander in one assigning statement ( technically you will be creating a new EventHandler delegate, passing the handle_clicks function to the delegate
constructor , and subscribing the delegate with the event )
Lets say you create button f at runtime as follows
Button f = new Button();
Then add the handler to its click event as follows
f.Click+= new System.EventHan dler(this. handle_clicks);
and anther button m
Button m = new Button();
m.Click+= new System.EventHan dler(this.handl e_clicks);
hope this was clear
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #4

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

Similar topics

2
11833
by: Paul | last post by:
I am trying to get a form to dynamicaly add hidden elements. Below is the function I've created, basicaly it loops thru an array and attempts to add those values to a newly created hidden input field which it then appends to the form. I works in IE, but in NN7 nothing is passed. function processAssortment(){ // get the form Element var formElement=document.getElementById("candyBoxForm"); //loop thru the candy box contents, add them to...
4
2858
by: ZhangZQ | last post by:
Is it possible to dynamicaly to local and call a function in Win32 dll(not a ..net assembly dll) in C# at run time, for example, a C# program popup a dialogbox to let use input which Win32 dll to be loaded, which function to be called, and what are the parameters to call the function. Thank you very much!
1
323
by: Daniel | last post by:
How do i dynamicaly load and unload a C# dll at runtime
3
1695
by: minigitoo | last post by:
Hi I try to get dynamicaly all requests made to DB2 I process like this: 1) I stop then start my instance of database in the db2 control center 2) I use : db2 update monitor switches using statement on 3) then: db2 get snapshot for dynamic sql on <MyDatabase> I manage to get logs between instant t1 and t2, but i would like to see dynamicaly request which come to db2. I mean i would like to see in a
1
2561
by: Roman Muntyanu | last post by:
Hi all, I created resource dll dynamicaly using this code AppDomain curDom = AppDomain.CurrentDomain; AssemblyName myAssemblyName = new AssemblyName(); imagesAssemblyName.Name = "Images"; AssemblyBuilder myAssemblyBuilder = curDom.DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.Save);
2
2183
by: Daniel | last post by:
how to create a gif or png dynamicaly in .aspx and return in response?
2
1333
by: Marc Nederhoff | last post by:
Hi all, Is it possible to add the <link rel="stylesheet"....> dynamicaly. All pages in my site use the same style sheet, and I don't want to add the link manualy because of maintenance. Marc
7
7770
by: moondaddy | last post by:
I want to dynamically create a JavaScript file and cache it on the client for re-use. I know how to write javascript to a web page from the code behind, but I don't know how to actually create a file such as MyNewScript.js and then cache that on the client so all the pages of that session can use it. Can this be done? Thanks -- moondaddy@nospam.com
3
1132
by: leon | last post by:
hello friends, i am writing a page aspx and creating controls dinamicaly and then i must to create for each control the events as well. Anybody to know how????? happy day lion
0
908
by: bala | last post by:
hi can anyone tell me how to create crystal report dynamicaly(runtime)
0
9527
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,...
1
10172
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
9050
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
7546
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
6785
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
5441
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...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
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
3730
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.