LinkButton in a placeholder control

  • Thread starter Thread starter egholm
  • Start date Start date
E

egholm

Hi

The code below is adding a dynamicly created LinkButton to a
placeholder control.
When I click the LinkButton it should call attLink_Click(), but it
dosen't happen.
What is wrong? Please help.

By the way, I'm using VS.NET 2005


//Code creating the LinkButton
LinkButton attLink = new LinkButton();
attLink.ID = "dummy";
attLink.Text = "blablabla";
attLink.Click += new EventHandler(attLink_Click);
phUploadedFiles.Controls.Add(attLink);



//Eventhandler
void attLink_Click(object sender, EventArgs e)
{
throw new Exception("The method or operation is not
implemented.");
}
 
The linkbutton needs to be re-added to the placeholder control during
postback on or before Page_Load. If you are adding this linkbutton within
an another event handler, or when !PAge.IsPostback, you'll need to do some
work to re-add it if it was previously added.

Karl
 
The linkbutton is added in another event handler, so that is where the
error is.
Thanks for your answer.
 
Back
Top