473,410 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Dynamically add linkbuttons and wire them to same event??

Hi,

How do I dynamically add linkbuttons and wire them to same event? I am able to add linkbuttons but they do not fire the event. Does anybody have a working sample?

Many thanks,

Linda
Nov 16 '05 #1
2 3690
Hi Linda,

If their events are not firing then I'm guessing you may be adding them too late in the execution lifecycle. At which point are you adding them? Also any short sample code you could provide will greatly help the guessing game.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx

To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
"Linda" <li***@do-not-spam.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

How do I dynamically add linkbuttons and wire them to same event? I am able to add linkbuttons but they do not fire the event. Does anybody have a working sample?

Many thanks,

Linda
Nov 16 '05 #2
Linda,

You have to add an event handler to the control that you added
dynamically. For the below example code I created a new ASP.NET
project and placed a PlaceHolder control on the form.

In the Page_Load event place the following code:

'Instance a link button
Dim MyLinkButton As New LinkButton

'Set the text
MyLinkButton.Text = "Click Here for Google"

'Dynamically add to Place Holder
PlaceHolder1.Controls.Add(MyLinkButton)

'Add an event handler to button
AddHandler MyLinkButton.Click, AddressOf HandleMyLinkButtonClick
Then create a sub (delagate) to handle the click. It must have the
parameters as in the example. This example redirects to Google.

Sub HandleMyLinkButtonClick(ByVal sender As Object, ByVal e As
System.EventArgs)
Response.Redirect("http://www.google.com")
End Sub
If you have multiple links pointing to the same Handler you could use
something like the following to determine which link was clicked:

SelectedItemText = CType(sender, LinkButton).Text
Hope that helps.
On Tue, 27 Apr 2004 17:35:10 -0700, "Linda" <li***@do-not-spam.com>
wrote:
Hi,

How do I dynamically add linkbuttons and wire them to same event? I am able to add linkbuttons but they do not fire the event. Does anybody have a working sample?

Many thanks,

Linda


Nov 16 '05 #3

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

Similar topics

3
by: Alice Lee | last post by:
Hi, My web from has one button and by clicking this button a list of linkbuttons must be dynamically displayed based on information in database. Then click any one of these linkbuttons another...
8
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...
2
by: djc | last post by:
On the page_load event I am querying a database and binding data to some text boxes, list boxes, and a repeater control. When the page loads it uses the value of one of the database fields (status)...
4
by: Jordan | last post by:
I need to dynamically add an ImageButton control to a user control and and do some server-side processing when the user clicks it. While I the ImageButton is added to the user control at runtime,...
0
by: viovanov | last post by:
I am trying to get some events to fire properly. I have a series of LinkButtons with some attribute set, one of which is unique for each LinkButton. At first I load a few buttons, and I set...
1
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...
0
by: Syoam4ka | last post by:
My project is about jewellery. I have devided my jewelery into main types, which each one of them has sub types, and each one those sub types has the jewellery. I have a tabcontainer. It includes...
2
by: Nathan Sokalski | last post by:
I have LinkButtons that are dynamically created in one of the PostBack events. They must be created in the PostBack event because one of the variables required to determine which ones to create...
8
by: Hamayun Khan | last post by:
Hi I have created linkbuttons dynamically using the below code Sub createlinkbutton(ByVal commandtext As String, ByVal Cmdarg As String, ByVal pane As Panel, ByVal count As Int32) Dim i =...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
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...
0
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...
0
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...

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.