Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

Handling Onclick Event from dynamically created linkbuttons (1.1)

 
 
RSH
Guest
Posts: n/a
 
      04-23-2007
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


 
Reply With Quote
 
 
 
 
rbg
Guest
Posts: n/a
 
      04-23-2007
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);
this.PlaceHolder1.Controls.Add(ctrl);

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

 
Reply With Quote
 
 
 
Reply

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
asp.net dynamically created button not firing onClick event rsaffy@nuvox.com 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



Advertisments