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

Handling Onclick Event from dynamically created linkbuttons (1.1)

RSH
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

ctrl.CommandName = "LoadUser"

ctrl.CommandArgument = dtrReader("EmailAddress") & ""

ctrl.Text = dtrReader("FullName")

AddHandler ctrl.Click, AddressOf LoadUser

PlaceHolder1.Controls.Add(ctrl)

Private Sub LoadUser(ByVal sender As Object, ByVal e As System.EventArgs)

.....

End Sub

Thanks,
Ron
Apr 23 '07 #1
1 5536
rbg
I just verified and the Event definately does fire:

Here is the C# version of the code:

LinkButton ctrl = new LinkButton();
ctrl.CommandName = "LoadUser";
ctrl.CommandArgument = "my*****@company.com";
ctrl.Text = "LoadUser";
ctrl.Click +=new EventHandler(ctrl_Click);
this.PlaceHolder1.Controls.Add(ctrl);

private void ctrl_Click(object sender, EventArgs e)
{
Response.Write("You just clicked the LinkButton named LoadUSER");
}

Apr 23 '07 #2

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

Similar topics

2
by: Linda | last post by:
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
6
by: James Norton-Jones | last post by:
Hi, I am wanting to create Linkbuttons and Event Handlers on the fly. Ideally I would be able to pass the CommandName and CommandArgument to the Event Handler which in turn would pass these to...
2
by: Jorge Ayala | last post by:
Well I'm trying to catch and act upon a button event that is placed within the item template of a repeater control. Yet the code I'm using isn't working. What I've seen out there to explain how...
2
by: hn | last post by:
Hi, I have linkbuttons created dynamically and they display fine on the web page. However, when I click on the those link buttons, the event doesn't fire. Please tell me what's wrong with the...
2
by: Pravin | last post by:
Hi All, In my application it is required that I create multiple instances of a linkbutton. I am assigning ID's to each of these buttons depending upon the sequence that they are created i.e., ID...
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...
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...
1
by: Nathan Sokalski | last post by:
I have a series of LinkButtons that I need to be able to handle the postback events for. The controls are created dynamically, and how many there will be will vary. I was previously told 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 =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.