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 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
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
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 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 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...
|
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!
|
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 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
|
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);
| |
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 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
|
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: 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,...
| |
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,...
|
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...
|
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...
|
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();...
|
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...
|
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |