Reference a control in a placeholder control

C

Chris Kettenbach

How do I get the page to respond to events on a dynamically loaded user
control in a placholder control?
I am trying to reference the control in the placeholder from my codebehind
for the page

On the calling page I have:
Protected WithEvents PH As System.Web.UI.WebControls.PlaceHolder

Protected WithEvents phMain As System.Web.UI.WebControls.PlaceHolder

Protected WithEvents btnCompanies As Button =
CType(Page.Controls("PH").Controls("btnCompanies"), Button)

Public Sub myCompBtn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCompanies.Click

phMain.Controls.Add(LoadControl("myctls\companies.ascx"))

End Sub

_________________

I get a "Input string was not in a correct format" error on the line where I
try to dimension the button. Any ideas how to correct the problem? Thanks
to everyone
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top