0

I've been racking my brain over this for a while, its been a while since I had to do this and know its possible I've done it in another project in the past that I don't have a backup of to refer to.

I have a Login View on a page inside the login view is 2 panels one panel with a login control (to login) and one panel with a createuserwizard (to register) and a second button to click to register.

I'm trying to hide the panel with the login control and show the panel with the register control via a button click but all I end up with is a null reference exception.

this is what I have currently.

protected void Register_Click(object sender, EventArgs e)
{
    FindControl("LoginView1").FindControl("LoginPanel").Visible = false;
    FindControl("LoginView1").FindControl("RegPanel").Visible = true;
}

I appreciate any help thanks.

1 Answers1

1

I figured out what the problem was so I'll leave the question here for anyone who may have the same problem and stumble across this

I was so used to working with controls from a master page but within a page that's inside the master page you don't need the first findcontrol its simply:

protected void Register_Click(object sender, EventArgs e)
{
    LoginView1.FindControl("LoginPanel").Visible = false;
    LoginView1.FindControl("RegPanel").Visible = true;
}