473,396 Members | 1,789 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,396 software developers and data experts.

Dynamically Added Linkbutton EventHandler

8
I知 really hoping someone can help me out on this. I知 adding a user control to a page that has, among other items, a link button. I知 trying to add an event handler to that link button. The control is added just fine, and the link button appears, but when I click on it, nothing happens.

Sub AddControl()
control_count = control_count + 1
Dim new_control As Control = New Control()
new_control = LoadControl("admin_distribute_points_line_items.as cx")
new_control.ID = "ctlLineItems" & control_count

Dim linkButtonCalc As LinkButton = new_control.FindControl("lbCalc")
AddHandler linkButtonCalc.Click, AddressOf linkButtonCalc_Click

plhDistribute.Controls.Add(new_control)
End Sub

Protected Sub linkButtonCalc_Click(ByVal sender As Object, ByVal e As EventArgs)
善ROBLEM: I NEVER GET HERE WHEN THE LINK BUTTON IS CLICKED
End Sub

Any ideas? Thanks!

Casey
Apr 16 '07 #1
3 1661
Your code worked fine for me.
I would verify the names of the controls you're loading.
For Example: You're trying to find lbCalc (usually people use lblCalc).

Does the control show up on the page?
Is there an error your getting?

Let me know if I can be of any more help


I知 really hoping someone can help me out on this. I知 adding a user control to a page that has, among other items, a link button. I知 trying to add an event handler to that link button. The control is added just fine, and the link button appears, but when I click on it, nothing happens.

Sub AddControl()
control_count = control_count + 1
Dim new_control As Control = New Control()
new_control = LoadControl("admin_distribute_points_line_items.as cx")
new_control.ID = "ctlLineItems" & control_count

Dim linkButtonCalc As LinkButton = new_control.FindControl("lbCalc")
AddHandler linkButtonCalc.Click, AddressOf linkButtonCalc_Click

plhDistribute.Controls.Add(new_control)
End Sub

Protected Sub linkButtonCalc_Click(ByVal sender As Object, ByVal e As EventArgs)
善ROBLEM: I NEVER GET HERE WHEN THE LINK BUTTON IS CLICKED
End Sub

Any ideas? Thanks!

Casey
Apr 16 '07 #2
Casey
8
It works? Hmm.

The names are correct. I usually use lbl____ for a label, and lb____ for a linkbutton. The linkbutton does show up on the page, and I can even change attributes of it, like the text.

A variable that I had not mentioned before is that the user has the ability to add as many of the user controls as they want, and each control contains a link button. so, when the page loads, the first control is loaded which contains a link button. When the user clicks an "Add" button (outside of the control) a new instance of the user control is added, with a another link button.

I have been working on this for too long. I need to find another way to skin this cat. Thanks for your help!

Casey
Apr 16 '07 #3
Sorry about the lbl... I've been working too long. I meant to say lnk_ for link.
I'll check to see if multiple controls load through the AddControl Sub.

It works? Hmm.

The names are correct. I usually use lbl____ for a label, and lb____ for a linkbutton. The linkbutton does show up on the page, and I can even change attributes of it, like the text.

A variable that I had not mentioned before is that the user has the ability to add as many of the user controls as they want, and each control contains a link button. so, when the page loads, the first control is loaded which contains a link button. When the user clicks an "Add" button (outside of the control) a new instance of the user control is added, with a another link button.

I have been working on this for too long. I need to find another way to skin this cat. Thanks for your help!

Casey
Apr 16 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Webgour | last post by:
Hi, I'm tring to add a column to a datagrid with a linkbutton as header that can be used to sort the column. The column and the linkbutton are added programmatically (see below). However the...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
0
by: sameer mowade via .NET 247 | last post by:
Hello All, I have problem while dynamically removing row from the Datagrid which i have added dynamically as shown in the following code snippet. The problem is that while removing dynamically...
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...
3
by: keithb | last post by:
My code dynamically adds template fields to a GridView control. Everything seems to work OK, except when updating, because I haven't found a way to reference the dynamically added textboxes....
5
by: =?Utf-8?B?TWFyYyBXb29sZnNvbg==?= | last post by:
Hi, I have a strange issue occurring with LinkButtons that are dynamically added to each (data) row of my DataGrid on that grid's ItemDataBound event. Each LinkButton is assigned its own event...
6
by: ree321 | last post by:
I have a linkbutton which is added to a column in a datagrid dynamically using a template I created. When I change the data in it by not databinding and then when I later retreive the data from 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...
4
by: jack | last post by:
Hi, Consider the following handler: protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e) { GridViewRow row = e.Row; if (row.RowType != DataControlRowType.DataRow)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
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用lanning, coding, testing,...

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.