When using the FindControl()immediate parent of a control out of context, you need to go through the control tree to find what level yours is labelat and call it .FindControl()at the appropriate level.
However, take @Andrew Hare's advice and rethink your architectural decisions. There is probably a better way for your UserControl to interact with its consumer page.
, UserControl ( / ). , , , .
, Error .
:
Public Event UserErrorOccured(ByVal ErrorText as String)
:
If Not Page.IsValid Then
RaiseEvent("The page is not valid")
End If
:
protected sub UserEventHandler(ByVal ErrorText as String) Handles MyUserControl.UserErrorOccured
errorLabel.Text = ErrorText
End Sub