I have a loginview , that is in master page. and in login mode of login control, I have a hyperlink. I want access to hyperlink , but I get error(Object not refrence …)
my code is :
HyperLink hp = FindControl("LoginView1_").FindControl("hpMng") as HyperLink;
The
FindControlmethod only searches for control that are under the collection of controls you looking for. It doesn’t do a full recursive search.And in your case, you can do something like this since you are on the same page (MasterPage)
Remember if the
HyperLinkcontrol is in theLoggedInTemplateit will only be available when the user is logged in. If theHyperLinkcontrol is in theAnonymousTemplatethe control will only be available when the user has not been logged in the application. Take this into consideration to avoid a null reference exception