tags:

views:

43

answers:

1

Hi all,

Trying to set up the Login control as a User control, but none of the controls exist in the current context? I also tried adding to a master page with the same error showing up.

None of my code below is recognised? What's going on here please? I've rebuilt the solution many times.

if (Membership.ValidateUser(this.UserName.Text, this.Password.Text))
    {
        FormsAuthentication.RedirectFromLoginPage(UserName.Text, RememberMe.Checked);
    }
    else
    {
         Msg.Text = "Login failed. Please check your user name and password and try again.";
    }
A: 

Make sure you have used the proper namespaces and the System.Web assembly is referenced in your project:

  • FormsAuthentication - defined in System.Web.Security namespace in the System.Web assembly
  • Membership - defined in System.Web.Security namespace in the System.Web assembly
Darin Dimitrov
Hi, thanks for the reply. Maing progress here, I had forgotten to add the System.Web.Security namespace, so FormsAuthentication and Mambership are now recognised. However the textbox controls are not being recognised. The error message is "login does not contain a definition for UserName and no extension method UserName"
Melt