Having a nested control under a
If a container control is not rendered, any controls that it contains
will not be rendered
public MyClass myVariable = null;
<asp:panel runat="server" Visible="false">
<img id="imgNotConfirmedPhoto" src="<%# myVariable.Whatever %>" />
Object reference not set to an instance of an object
As you can see in MSDN: ASP.NET Page Life Cycle Overview, the entire page will be parsed and loaded long before they will be rendered.
This includes controls that won't be visible after rendering (for example when they, or their parent controls have
Visible = false).
So whether a control will be rendered or not, it will be parsed and loaded, and its properties will be evaluated, causing the exception you see.