ok I have gotten a bit further on the password protection page but now Im having difficulities trying to get an Error message appear if the credtials are invalid. Here is the code.<BR>login.aspx.vb:<BR>Imports System.Data.SqlClient<BR>Imports System.Web.Security<BR><BR>Public Class logon<BR> Inherits System.Web.UI.Page<BR> Protected WithEvents vUserName As System.Web.UI.WebControls.RequiredFieldValidator<BR> Protected WithEvents vUserPass As System.Web.UI.WebControls.RequiredFieldValidator<BR> Protected WithEvents chkPersistCookie As System.Web.UI.WebControls.CheckBox<BR> Protected WithEvents lblMsg As System.Web.UI.WebControls.Label<BR> Protected WithEvents txtUserName As System.Web.UI.HtmlControls.HtmlInputText<BR> Protected WithEvents txtUserPass As System.Web.UI.HtmlControls.HtmlInputText<BR> Protected WithEvents cmdLogin As System.Web.UI.WebControls.LinkButton<BR> Protected WithEvents newuser As System.Web.UI.WebControls.LinkButton<BR> Protected WithEvents Label As System.Web.UI.WebControls.Label<BR>#Region " Web Form Designer Generated Code "<BR><BR> 'This call is required by the Web Form Designer.<BR> <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<BR><BR> End Sub<BR><BR> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init<BR> 'CODEGEN: This method call is required by the Web Form Designer<BR> 'Do not modify it using the code editor.<BR> InitializeComponent()<BR> End Sub<BR><BR>#End Region<BR><BR> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<BR> 'Put user code to initialize the page here<BR> End Sub<BR><BR> Function ValidateUser(ByVal uid As String, ByVal passwd As String) As Boolean<BR> Dim cnn As SqlConnection<BR> Dim cmd As SqlCommand<BR> Dim dr As SqlDataReader<BR> Dim retVal As Boolean = False<BR> cnn = New SqlConnection("server=localhost;uid=sa;pwd=trinity;database=Pubs;")<BR> cmd = New SqlCommand("Select * from users where uname = '" & uid & "'", cnn)<BR> cnn.Open()<BR> dr = cmd.ExecuteReader()<BR> While (dr.Read())<BR> If StrComp(dr.Item("Pwd"), passwd, 1) = 0 Then<BR> retVal = True<BR> End If<BR> End While<BR> cnn.Close()<BR> ValidateUser = retVal<BR> End Function<BR><BR> Private Sub cmdLogin_Click(ByVal sender As Object, _<BR> ByVal e As System.EventArgs) Handles cmdLogin.Click<BR> If ValidateUser(txtUserName.Value, txtUserPass.Value) Then<BR> Dim tkt As FormsAuthenticationTicket<BR> Dim cookiestr As String<BR> Dim ck As HttpCookie<BR><BR> tkt = New FormsAuthenticationTicket(1, txtUserName.Value, DateTime.Now(), _<BR> DateTime.Now.AddMinutes(30), chkPersistCookie.Checked, "ryandunn cookie control")<BR> cookiestr = FormsAuthentication.Encrypt(tkt)<BR> ck = New HttpCookie(FormsAuthentication.FormsCookieName(), cookiestr)<BR> If (chkPersistCookie.Checked) Then ck.Expires = tkt.Expiration<BR> Response.Cookies.Add(ck)<BR><BR> Dim strRedirect As String<BR> strRedirect = Request("ReturnURL")<BR> If strRedirect <> "" Then<BR> Response.Redirect(strRedirect, True)<BR> Else<BR> strRedirect = "default.aspx"<BR> Response.Redirect(strRedirect, True)<BR> End If<BR> Else<BR> Label.Text = "Invalid Credentials: Please try again"<BR> End If <BR> End Sub<BR><BR><BR>End Class<BR><BR>And Im trying to call it from the login.aspx from this:<BR><asp:Label id="Label" ForeColor="red" Font-Name="Verdana" Font-Size="10" runat=server />Haha, well, first thing I'd try is renaming your label to be something OTHER than the word "label" I've run into issues before when naming a control the same thing as the control itself. <BR><BR>After you've done that, does it return an error? or just do nothing?<BR><BR>])ryrenamed it and it just does nothing, no errors.just after your LabelName.Text = "whatever" write something like this:<BR><BR>Response.write("Label value=http://aspmessageboard.com/archive/index.php/" & labelName.text)<BR><BR>If your class writes out "Label value=" at least you know it's getting that far. Most times my apps "do nothing" it's because they aren't even getting to the point in question. Also might try changing your label to a span and use spanName.InnerHtml = "message" to see if you have any better luck. <BR><BR>Just an idea, I'm by no means an expert at this stuff, just got thrown into it like the rest of us
<BR><BR>])ry
