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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top