PC Review


Reply
Thread Tools Rate Thread

Dynamically created Linkbutton onclick not working...

 
 
Sheryl Landon
Guest
Posts: n/a
 
      6th Apr 2005
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)

{

}


 
Reply With Quote
 
 
 
 
Brock Allen
Guest
Posts: n/a
 
      6th Apr 2005
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)
>
> {
>
> }
>




 
Reply With Quote
 
 
 
 
Sheryl Landon
Guest
Posts: n/a
 
      6th Apr 2005
OMG, duh, thanks!

"Brock Allen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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)
>>
>> {
>>
>> }
>>

>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
how to know which dynamically created linkbutton has been clicked? Bob Microsoft ASP .NET 3 2nd Apr 2009 11:19 AM
asp.net dynamically created button not firing onClick event rsaffy@nuvox.com Microsoft ASP .NET 7 20th Jul 2006 10:02 PM
Linkbutton does not look like a linkbutton Sathyaish Microsoft ASP .NET 3 8th Sep 2005 10:41 AM
Event on dynamically created linkbutton in C# Alice Lee Microsoft C# .NET 3 5th Jun 2004 09:37 AM
dynamically created linkbutton within custom control =?Utf-8?B?ZGF2ZQ==?= Microsoft Dot NET 3 28th Jan 2004 09:37 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:05 PM.