내가이 오류가 발생했습니다형식 또는 네임 스페이스 이름 'WebControls'은 (당신은 using 지시문 또는 어셈블리 참조가?)
The type or namespace name 'WebControls' could not be found (are you missing a using directive or an assembly reference?)
소스 오류 :
Line 28: Login Login1 = (WebControls.Login)LoginView1.FindControl("Login1"); // here the error code
Line 29: TextBox UserName = (TextBox)Login1.FindControl("UserName");
Line 30: TextBox FailureText = (TextBox)Login1.FindControl("FailureText");
을 몇 가지 조사를 해본 결과 해결책을 소스 코드에 추가하는 것이 었습니다.
코드를 추가 할 수 있습니다. 처음에는 네임 스페이스로 넣으려고했으나 잘못되었습니다. 누구든지 어디에서이 코드를 사용해야한다고 말할 수 있습니까 ??
편집 당신은 모든 네임 스페이스와 클래스 이름 자체를 포함하여 클래스의 전체 이름, 지정해야
protected void Login1_LoginError(object sender, System.EventArgs e)
{
//Login Login1 = (WebControls.Login).LoginView1.FindControl("Login1");
Login Login1 = (System.Web.UI.WebControls.Login)LoginView1.FindControl("Login1");
TextBox UserName = (TextBox)Login1.FindControl("UserName");
TextBox FailureText = (TextBox)Login1.FindControl("FailureText");
//There was a problem logging in the user
//See if this user exists in the database
MembershipUser userInfo = Membership.GetUser(UserName.Text);
if (userInfo == null)
{
//The user entered an invalid username...
FailureText.Text = "There is no user in the database with the username " + UserName.Text;
}
else
{
//See if the user is locked out or not approved
if (!userInfo.IsApproved)
{
FailureText.Text = "When you created your account you were sent an email with steps to verify your account. You must follow these steps before you can log into the site.";
}
else if (userInfo.IsLockedOut)
{
FailureText.Text = "Your account has been locked out because of a maximum number of incorrect login attempts. You will NOT be able to login until you contact a site administrator and have your account unlocked.";
}
else
{
//The password was incorrect (don't show anything, the Login control already describes the problem)
FailureText.Text = string.Empty;
}
}
}
line28의 코드는 다음과 같아야합니다. WebControls.Login Login1 = (WebControls.Login) LoginView1.FindControl ("Login1") ;. 또한 using System.Web을 사용해야합니다..cs 파일의 맨 위에있는 UI 네임 스페이스 – Rajesh