Really stupid ATM ... why can't I link to Master.FindControl?

oPanel = CType(Master.FindControl("panelSearch"), Panel)

This code is on my main page master page ( theMaster.master.vb

), but I get the message "Can't reference an instance member from a shared or partial initializer element without an explicit instance of the class"

the function it is in separates IS, I just can't remember how much I have to do this to make this work.

thank!

0


source to share


2 answers


Remove the modifier Shared

in your method where this code is written.



+2


source


You cannot access the main property of the page from a generic function. You must make the function an instance function (remove the Shared keyword) before you can use the Master property.



+1


source







All Articles