Re: Dynamically loading user control into Placeholder gives Object reference not set to an instance of an object

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I found the problem, i wasn't calling
Page.LoadControL("ucMySectorFilters.ascx") before adding the
control...duh.

Here's the working code (hopefully it will help out someone else!):

Dim mySectorFiltersControl As ucMySectorFilters = New ucMySectorFilters
mySectorFiltersControl =
Page.LoadControl("ucMySectorFilters.ascx")
mySectorFiltersControl.listBoxStyle =
ucMySectorFilters.enlistBoxStyle.ContentPage
PlaceHolder1.Controls.Add(mySectorFiltersControl)

.