LinkButton in a placeholder control

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.");
}
 
K

Karl Seguin

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
 
E

egholm

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top