Because you've said that you want "a reference to itself", i assume that you want a reference to the button that has caused the click-event.
The easiest is to use the sender
argument, because that's always the source control:
Dim button = DirectCast(sender, Button)
But when the button is on top of the page(as in this case), the reference to the control is automatically created in the partial designer.vb
file:
EntryDoor1.Visible = False
So why using FindControl
if you have a direct reference anyway?!
Edit:
Just for the sake of completeness. The behaviour you're describing can only have one reason: You're trying to use FindControl
in a ContentPage
of a MasterPage
. This is a special case, you need to get the reference to the ContentPlaceholder
first. Then you can use FindControl
for your Button
:
Dim button = DirectCast(Page.Master.FindControl("ContentPlaceHolder1").FindControl("EntryDoor1"), Button)
But again, this is pointless since you have the reference in the page directly.