473,618 Members | 3,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Call a function from a dynamically created ImageButton

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

Jul 21 '05 #1
1 1748
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 = "OnlyCallFuncti onOne";
someButton.Clic k += new EventHandler( DynamicButton_C lick );

Button someOtherButton = new Button();
someOtherButton .Name = "OnlyCallFuncti onTwo";
someOtherButton .Click += new EventHandler( DynamicButton_C lick );

// then you have the Click function
private void DynamicButton_C lick( object sender, EventArgs e )
{
Button btn = (Button)sender;
switch( btn.Name )
{
case "OnlyCallFuncti onOne": this.FunctionOn e(); break;
case "OnlyCallFuncti onTwo": 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....the n again i only use c# (^_^)

"Patrick Marti" <Pa**********@d iscussions.micr osoft.com> wrote in message
news:6C******** *************** ***********@mic rosoft.com...
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

Jul 21 '05 #2

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

Similar topics

3
5505
by: Jim Mitchell | last post by:
I have some code behind that generates 10 imagebutton controls.... I can not seem to figure out how to trap the onclick event for each image and determine which image was clicked. Can someone help? Thanks in advance. for i = 1 to 10 img = New System.Web.UI.WebControls.ImageButton
4
4279
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage I know I need to call a function that will save data but I'm not sure exactly when to call this function. I've tried two ways and both seem to have 'gotcha's':
2
2160
by: Danny Bloodworth | last post by:
I have a usercontrol (login.ascx) that is very simple. It accepts input through two textboxes, and then the user clicks an Imagebutton to submit. I have a parent form that checks the page security (security level needed) against current user security (stored in the context object) and if user security >= level needed to view page then dynamically loads a content control and displays content
2
3734
by: Jose Suero | last post by:
Hi all I have a dynamically created button, I can add an event handler with: AddHandler button.click, AddressOf static_function This works great, but what I need is to create a function that takes the control, the event and the function as parameters, something like: function addevent(control as object, event as string, functionname as string)
8
4309
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image button at runtime: //----- Code snippet protected System.Web.UI.WebControls.PlaceHolder ImageHolder; private void Page_Load(object sender, System.EventArgs e)
3
2209
by: tony collier | last post by:
Help please. I have a list of items on my page, alongside each of which i have a DELETE imagebutton. There can be from 0 to 6 items in the list and they are placed in a table which cannot be dynamically generated, therefore i have 6 imagebuttons (for DELETE) and 6 labels (for item name) placed in the table. There is a string array labelText such that i have label0.Text=labelText; label1.Text=labelText;
2
2915
by: R Duke | last post by:
I have tried everything I can think of to change the visible property of a design time created control from a dynamically created control's command event handler. Here is the scenario. I have a WebForm with some textboxes, dropdownlists, a panel, imagebutton and so on. When I click on the image button (which was created at design time) I dynamically build a table. In each of row of that new table I put several cells and one cell...
2
1962
by: Bruce | last post by:
I have a button on a form that creates multiple ImageButtons; I want each ImageButton's click event to then redirect to another URL. From doing some research, I understand this has to do with ImageButtons (and their handlers) not being re-assigned on postback, but how do I accomplish the above? .... ImageButton ib = new ImageButton(); ib.Width = 100; ib.Height = 80; ib.ImageUrl = @"http://mysite.com/images/image1.jpg";
1
301
by: Patrick Marti | last post by:
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
0
8653
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...
0
8595
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8304
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
8455
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7126
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
6101
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
5552
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
4065
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...
2
1459
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.