FindControl for Web User Control
Posted on 2004-08-24
I seem to have a problem. (as most of us who ask a question)
I am adding a web user control in a sharepoint webpart(this is just like a normal asp.net page so don't worry about that :)). I add this control in de Render method using:
Before I add this control (or after, neither seem to work), I add an ID to it using:
MyControl.ID = "Test"
When the page refreshes I check to see if the control already exists (in the init method) using:
ObjMyControl = CType(Me.Page.FindControl("Test"), MyControl)
if ObjMyControl is nothing then
ObjMyControl = new MyControl
It never finds this control ? Any ideas why this doesn't work.
(the problem is that I set some properties of that control and if I cant find that control It will make a new instance and I loose all of my set properties)