Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Handling Onclick Event from dynamically created linkbuttons (1.1)

Thread Tools

Handling Onclick Event from dynamically created linkbuttons (1.1)

Posts: n/a

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


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


End Sub


Reply With Quote
Posts: n/a
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 = "(E-Mail Removed)";
ctrl.Text = "LoadUser";
ctrl.Click +=new EventHandler(ctrl_Click);

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

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM dynamically created button not firing onClick event ASP .Net 7 07-20-2006 09:02 PM
Managing ViewState of a dynamically created Custom Composite Server Control -(where the original is also dynamically created) dickster ASP .Net Building Controls 0 12-08-2005 09:32 AM
Accessing OnClick event for dynamically created controls. Jim Mitchell ASP .Net Web Controls 3 08-13-2003 02:54 AM
Creating onClick event for dynamically (programatically) created buttons Hrvoje Vrbanc ASP .Net 1 07-10-2003 04:55 PM