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
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