473,661 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating onClick event for dynamically (programaticall y) created buttons

Hello all!

My question is the following: I add buttons (server controls)
programatically into a table cell. Example:

Dim btObnovi As Button = New Button()
celija25.Contro ls.Add(btObnovi )

The number of rows in the table depends on number of records in a database.
Therefore, the number of buttons is variable.
Every button, naturally, gets its own ClientID (_ctl0, ctl1, etc.). But how
I determine which button was clicked and how do I set up OnClick event for
particular buttons?
I would like to take a text from a text box in the row where the button was
clicked and then to manipulate it. But first, I need to know how to write a
onClick sub.

Thank you very much in advance.

Hrvoje
Nov 17 '05 #1
1 3330
I'm speaking about adding the event handler, of course.
I realized I didn't write what I really want clearly.

Hrvoje

"Hrvoje Vrbanc" <hr*****@recro. hr> wrote in message
news:e7******** *****@TK2MSFTNG P10.phx.gbl...
Hello all!

My question is the following: I add buttons (server controls)
programatically into a table cell. Example:

Dim btObnovi As Button = New Button()
celija25.Contro ls.Add(btObnovi )

The number of rows in the table depends on number of records in a database. Therefore, the number of buttons is variable.
Every button, naturally, gets its own ClientID (_ctl0, ctl1, etc.). But how I determine which button was clicked and how do I set up OnClick event for
particular buttons?
I would like to take a text from a text box in the row where the button was clicked and then to manipulate it. But first, I need to know how to write a onClick sub.

Thank you very much in advance.

Hrvoje

Nov 17 '05 #2

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

Similar topics

2
2521
by: Richard Morse | last post by:
Hi! I have an aspx that I've created which has an asp:Button in it. I would like to be able to change the OnClick handler at runtime (basically, I want this form to either edit or create a record, and I want to change the procedure it calls depending on what it should be doing). However, apparently the .OnClick member is read only? (Sample:) <script language="jscript"> function do_edit() {
0
3157
by: Diane Yocom | last post by:
I'm very new to ASP.Net and probably jumped in a little over my head, but... I'm trying to create a user control that will control navigation through my site. It's sortof like Amazon.com, where there are tabs at the top with "submenu" buttons showing below the selected tab. The data that defines the tabs and submenus is stored in an XML file and I'm using nested repeaters to build them dynamically. I've got it working pretty well, except...
9
14442
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it does not. The problem is that the webcontrols get created on the OnLoad event of the usercontrol and the event handlers are assigned at the same time. I have to click twice on the controls for the events to be raised, the first time nothing...
5
12544
by: sam | last post by:
Hi all, I am dynamically creating a table rows and inerting radio buttons which are also dynamically created. Everything works fine in Firefox as expected. But I am not able to select radio buttons in IE. It does not even throw any errors. I have searched over the net but could not find anyhelp. Hope some experts here could help me. Here is part my code that dynamically generates the radio buttons, I cannot paste the entire code as it is...
7
3567
by: rsaffy | last post by:
I am having trouble with my dynamically created button's event handling. I read that the buttons need to be recreated on every trip to the server, but how exactly do you do that when the datagrid the button is added to is created at run time? here is code from my aspx page... ------------------------------------------------------------------------------------- <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">...
2
4564
by: =?Utf-8?B?TWlrZSBSYW5k?= | last post by:
I have created a method that dynamically creates a single button control (as a proof-of-concept, I would like to be able to create multiple buttons). I set properties on this control including an event handler for the click event. The problem is that when I click the button on the page and view the locals window in debug mode, I don't see any information on the button control. Say, I want to create a variable number of buttons based on...
1
5547
by: RSH | last post by:
Hi, I have a page that is generating Linkbuttons dynamically. I need to dynamically wire up the buttons to an OnClick handler server side. I am using this code but they are not firing the event. What am i missing? Dim ctrl As New LinkButton
5
2297
by: tshad | last post by:
I found I can create Template columns dynamically - as long as I don't use objects that need onclick events, such as a LinkButton. Textboxes and Labels work fine. I create the Template columns like so: Dim column as TemplateColumn = new TemplateColumn() column.HeaderText = "Template Column" column.ItemStyle.Width = Unit.Pixel(width) column.HeaderStyle.Width = Unit.Pixel(width)
4
1798
by: ShutterMan | last post by:
I have a function that creates input buttons dynamically... function $NEW_BUTTON(id, content, parentId, cssclass, onclick) { var ctrl = document.createElement("input"); ctrl.id = id; ctrl.setAttribute("name", id); ctrl.setAttribute("value", content); ctrl.setAttribute("class", cssclass); ctrl.setAttribute("type", "button");
0
8343
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,...
0
8855
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...
1
8545
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
7364
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...
0
4179
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
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
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
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1743
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.