User controls and placeholder?
I have a webform where I use 50 different user controls. I have solved the problem with help from DANIEL (thanks again) by adding the user controls to a placeholder. But I have a problem:
How do I call functions in the the user controls? I receive an error saying:
Code:
Object reference not set to an instance of an object
Everything is working well when I just place the user control on the form, but that is not smart to do when I have 50 controls. So I have checked that there is nothing wrong with the code below as long as the user control is not placed in the placeholder.
What is wrong?
Code:
Dim ctlCond1Abs As Control = LoadControl("Cond1Abs.ascx")
Dim ctlCond1Black As Control = LoadControl("Cond1Black.ascx")
Sub SetLanguage()
Page.Controls.Add(ctlCond1Abs)
plh1.Controls.Add(ctlCond1Abs)
cond1Abs1.LangArray1 = clsLanguage1.getLanguage(session("language"))
cond1abs1.setLanguage()
End Sub
1 Attachment(s)
Re: User controls and placeholder?
This is an example of a project with some simple code which illustrates my problem.
Re: User controls and placeholder?
I think I just answered this but
you do a PlaceHolder.FinderControl(id) and cats that control to your user contral class and call the method