473,508 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically created Linkbutton onclick not working...

Hi all - I'm creating a link button at runtime, and putting in a table cell,
and then trying to hook up the click event handler... but it's not working.
Here's the code, any idea what might be wrong? Thanks!!! Sheryl

private void AddTopicToTable(dsPersonnelDevelopment m_dsPD)

{

.... other stuff

btnAddTraining = new System.Web.UI.WebControls.LinkButton();

btnAddTraining.CssClass="Button";

btnAddTraining.Text= "Insert New Training";

btnAddTraining.ID="btnAddTraining";

oCell.Controls.Add(btnAddTraining);

btnAddTraining.Click += new System.EventHandler(this.btnAddTraining_Click);

}

public void btnAddTraining_Click(object sender, System.EventArgs e)

{

}
Nov 19 '05 #1
2 2124
Any dynamically created controls need t be recreated upon postback. If this
code is in your page class, then this is typically done in Page_Init (but
can be done elsewhere).

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi all - I'm creating a link button at runtime, and putting in a table
cell, and then trying to hook up the click event handler... but it's
not working. Here's the code, any idea what might be wrong? Thanks!!!
Sheryl

private void AddTopicToTable(dsPersonnelDevelopment m_dsPD)

{

... other stuff

btnAddTraining = new System.Web.UI.WebControls.LinkButton();

btnAddTraining.CssClass="Button";

btnAddTraining.Text= "Insert New Training";

btnAddTraining.ID="btnAddTraining";

oCell.Controls.Add(btnAddTraining);

btnAddTraining.Click += new
System.EventHandler(this.btnAddTraining_Click);

}

public void btnAddTraining_Click(object sender, System.EventArgs e)

{

}


Nov 19 '05 #2
OMG, duh, thanks!

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:37**********************@msnews.microsoft.com ...
Any dynamically created controls need t be recreated upon postback. If
this code is in your page class, then this is typically done in Page_Init
(but can be done elsewhere).

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi all - I'm creating a link button at runtime, and putting in a table
cell, and then trying to hook up the click event handler... but it's
not working. Here's the code, any idea what might be wrong? Thanks!!!
Sheryl

private void AddTopicToTable(dsPersonnelDevelopment m_dsPD)

{

... other stuff

btnAddTraining = new System.Web.UI.WebControls.LinkButton();

btnAddTraining.CssClass="Button";

btnAddTraining.Text= "Insert New Training";

btnAddTraining.ID="btnAddTraining";

oCell.Controls.Add(btnAddTraining);

btnAddTraining.Click += new
System.EventHandler(this.btnAddTraining_Click);

}

public void btnAddTraining_Click(object sender, System.EventArgs e)

{

}


Nov 19 '05 #3

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

Similar topics

3
5472
by: Jim Mitchell | last post by:
I have some code behind that generates 10 imagebutton controls.... I can not seem to figure out how to trap the onclick event for each image and determine which image was clicked. Can someone...
3
10773
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would...
0
2456
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...
4
2185
by: Mike Lowery | last post by:
I have an ASP.Net page that simply generates a dynamic page using Response.Write() statements to generate the HTML. This works great except that one of the things I want to generate is a...
5
6743
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
5
4698
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...
5
2291
by: tshad | last post by:
I found I can create Template columns dynamically - as long as I don't use objects that need onclick events, such as a LinkButton. Textboxes and Labels work fine. I create the Template columns...
3
3520
by: pbd22 | last post by:
Hi. How do I add the runat=server attribute on a buttonfield link dynamically? thanks!
3
5240
by: Allen Chen [MSFT] | last post by:
Hi Richard, Quote from Richard================================================== However I also want to be able to remove the panes. I have tried to include this, but find that when I first...
0
7231
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
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7066
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
7504
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
5643
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—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4724
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...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
435
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.