Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

web forms authentication 1

Status
Not open for further replies.

neomax

Programmer
Jul 1, 2006
29
BG
I've got 3 files, "login.aspx, login.aspx.cs, Default.aspx"

login.aspx:
<%@ Page src="Login.aspx.cs" Inherits="login" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<body>
<form id="Form1" runat="server">
<center>
<h3>
<font face="Verdana" color="blue">Login Page</font>
</h3>
<table>
<tr>
<td>
Email:
</td>
<td>
<input id="UserEmail"
type="text"
runat="server"
size="30" />
</td>
<td>
?????? ?????????? ?????????? ? ASP.NET
<ASP:RequiredFieldValidator ID="RequiredFieldValidator1"
ControlToValidate="UserEmail"
Display="Static" ErrorMessage="*"
runat="server" />
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<input id="UserPass"
type="password"
runat="server" size="30" />
</td>
<td>
<ASP:RequiredFieldValidator ID="RequiredFieldValidator2"
ControlToValidate="UserPass"
Display="Static" ErrorMessage="*"
runat="server" />
</td>
</tr>
<tr>
<td colspan="3" align="center">
<asp:button ID="Button1" text="Login"
OnClick="Login_Click"
runat="server">
</asp:button>
<P>
<asp:Label id="Msg" ForeColor="red"
Font-Name="Verdana"
Font-Size="10" runat="server" />
</td>
</tr>
</table>
</center>
</form>
</body>
</html>
----------
login.aspx.cs:

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Drawing;
using System.Web.Security;

public class Login: Page
{
protected RequiredFieldValidator RequiredFieldValidator1;
protected RequiredFieldValidator RequiredFieldValidator2;
protected Button Button1;

void Login_Click(object sender, EventArgs e)
{
// ?????????????? ????????????: ? ???? ??????? ???? ???????????
// ???? ???????????? doug@programmingasp.net
// ? ??????? 'password'
if ((UserEmail.Value == "doug@programmingasp.net") &&
(UserPass.Value == "password"))
{
FormsAuthentication.RedirectFromLoginPage(UserEmail.Value, false);
}
else
{
Msg.Text = "Invalid Credentials: Please try again";
}
}
}

and error:
Compiler Error Message: CS0103: The name 'UserEmail' does not exist in the current context


Line 21: if ((UserEmail.Value == "doug@programmingasp.net") &&
Line 22: (UserPass.Value == "password"))
Line 23: {

Please, help me to find the reason of erorr
 
can u try to add...

public class Login: Page
{
protected RequiredFieldValidator RequiredFieldValidator1;
protected RequiredFieldValidator RequiredFieldValidator2;
protected Button Button1;
protected HTMLInputText UserEmail;
...
 
it's not helps
Compiler Error Message: CS0246: The type or namespace name 'HTMLInputText' could not be found (are you missing a using directive or an assembly reference?)


Line 13: protected RequiredFieldValidator RequiredFieldValidator2;
Line 14: protected Button Button1;
Line 15: protected HTMLInputText UserEmail;
Line 16:


 
make sure you have at least these reference at the top of your code behind file...

using System;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
 
i see u do...

why are u using an Input anyway?

why not an <asp:TextBox />???

Does your RFV work with your Input?
 
thanks adamroof, you show me the way,

the reason is that
protected HtmlInputControl UserEmail;
protected HtmlInputControl UserPass;

not

protected HTMLInputText UserEmail;)))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top