PlaceHolder Control

R

Robin Hearne

I'm trying to add linkbuttons to a page programmatically
by adding them as child elements to a PlaceHolder
control. I've been able to add the linkbuttons to the
page but I can't get the 'onclick' event to work
correctly.

I've tried the following:
Dim btnClick As LinkButton = New LinkButton()
btnClick.ID = "Button1"
btnClick.Text = "Button 1"
btnClick.Attributes.Add("OnClick", "Button1_Click")
PlaceHolder1.Controls.Add(btnClick)

and included a Button1_Click subroutine to handle to
onclick event but I get a runtime error 'Button1_Click'
is undefined when the button is clicked.

Any ideas where I'm going wrong?

Thanks,


Robin
 

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,771
Messages
2,569,587
Members
45,099
Latest member
AmbrosePri
Top