PC Review


Reply
Thread Tools Rate Thread

Call a function from a dynamically created ImageButton

 
 
=?Utf-8?B?UGF0cmljayBNYXJ0aQ==?=
Guest
Posts: n/a
 
      17th Feb 2005
Is it possible to call a function from a ImageButton wich I create
at runtime?

That would be really interesting

Many thanks for any suggest.

Greetings Patrick Marti

 
Reply With Quote
 
 
 
 
Felipe
Guest
Posts: n/a
 
      18th Feb 2005
Hi Patrick

I would do it like this:

// this is created at runtime... maybe in onLoad or by another function....
Button someButton = new Button();
someButton.Name = "OnlyCallFunctionOne";
someButton.Click += new EventHandler( DynamicButton_Click );

Button someOtherButton = new Button();
someOtherButton.Name = "OnlyCallFunctionTwo";
someOtherButton.Click += new EventHandler( DynamicButton_Click );

// then you have the Click function
private void DynamicButton_Click( object sender, EventArgs e )
{
Button btn = (Button)sender;
switch( btn.Name )
{
case "OnlyCallFunctionOne": this.FunctionOne(); break;
case "OnlyCallFunctionTwo": this. FunctionTwo(); break;
}
}

private void FunctionOne()
{
// Some code...
}

private void FunctionTwo()
{
// Some code...
}


I just noticed you said ImageButton..... it should work just the same.

Hope it helps... did it in C# since u did not specify any other
language....then again i only use c# (^_^)

"Patrick Marti" <(E-Mail Removed)> wrote in message
news:6C9A095B-EDD8-4EB5-9162-(E-Mail Removed)...
> Is it possible to call a function from a ImageButton wich I create
> at runtime?
>
> That would be really interesting
>
> Many thanks for any suggest.
>
> Greetings Patrick Marti
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I call a dynamically created String in a VBA Sub izimmer@gmail.com Microsoft Excel Programming 4 25th Dec 2006 02:36 PM
Dynamically create and call a function MRW Microsoft ASP .NET 7 6th Aug 2006 11:58 PM
Dynamically created ImageButton with events =?Utf-8?B?QnJ1Y2U=?= Microsoft ASP .NET 2 12th Apr 2005 04:03 PM
Do a call from a dynamically created button? Gary Kahrau Microsoft VB .NET 3 14th Dec 2004 09:17 AM
Can you dynamically build a function call ? Simon Microsoft VB .NET 3 10th Oct 2003 07:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:02 PM.