Linkbutton - logout

I am not sure what my code can't find "lbtnlogout" linkbutton?

This is from Masterpage.

 <div class="loginDisplay">
                <asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
                        Internal<br />
                        <asp:LinkButton ID="lbtnlogout" runat="server" OnClick="lbtnlogout_Click">[Log Out]</asp:LinkButton>
                        <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutText="Log Out" OnLoggedOut="Logged_Out" />


    Dim lv As LoginView = CType(Page.Master.FindControl("HeadLoginView"), LoginView)
            Dim newLB As LinkButton = CType(lv.FindControl("lbtnlogout"), LinkButton)  <<< can't find lbtnlogut
            newLB.Visible = False
Who is Participating?
guru_samiConnect With a Mentor Commented:
Are you sure you are not accessing when you are logged-in i.e. user is not authenticated?
When you are not logged-in then only lbtnlogout is accessible otherwise once you login, you will still see "Log Out' but that will be from the LoginStatus control.
VBdotnet2005Author Commented:
Yes, I am sure. They have not yet logged-in. I just tried to load the page. That's what I get.
VBdotnet2005Author Commented:
This is the error I keep getting "Object reference not set to an instance of an object. "
This line - newLB.Visible = False
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.