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 3 1789
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.EventArgs 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.EventHandler(this. handle_clicks);
and anther button m
Button m = new Button();
m.Click+= new System.EventHandler(this.handle_clicks);
hope this was clear
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
yes, yes.
I have associate it for the handler and that's it.
Thank's a lot
leon.
"Mohamoss" <mo************@egdsc.microsoft.com> wrote in message
news:t7**************@cpmsftngxa06.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.EventArgs 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.EventHandler(this. handle_clicks); and anther button m Button m = new Button(); m.Click+= new System.EventHandler(this.handle_clicks); hope this was clear Mohamed Mahfouz MEA Developer Support Center ITworx on behalf of Microsoft EMEA GTSC
Hey Mohamed, thanks a lot.
I have done you words and that's it, very easy man.
thanks.
lion.
"Mohamoss" <mo************@egdsc.microsoft.com> wrote in message
news:t7**************@cpmsftngxa06.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.EventArgs 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.EventHandler(this. handle_clicks); and anther button m Button m = new Button(); m.Click+= new System.EventHandler(this.handle_clicks); hope this was clear Mohamed Mahfouz MEA Developer Support Center ITworx on behalf of Microsoft EMEA GTSC This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
by: Daniel |
last post by:
How do i dynamicaly load and unload a C# dll at runtime
|
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...
|
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";...
| |
by: Daniel |
last post by:
how to create a gif or png dynamicaly in .aspx and return in response?
|
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
|
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...
|
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
|
by: bala |
last post by:
hi can anyone tell me how to create crystal report dynamicaly(runtime)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
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: 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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 ...
|
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...
| |