Jump to content


Photo

Login Em .net


  • Faça o login para participar
1 reply to this topic

#1 wozniak

wozniak

    Hands-On Founder

  • Usuários
  • 578 posts
  • Sexo:Masculino
  • Localidade:Rio de Janeiro / RJ

Posted 10/12/2003, 09:53

<%@ Page Language="VB" %>
<script runat="server">

    Sub LoginBtn_Click(Sender As Object, E As EventArgs)
    
        If Page.IsValid Then
            If (UserName.Text = "email@provedor.com") And (UserPass.Text = "password") Then
                FormsAuthentication.RedirectFromLoginPage(UserName.Text, true)
            Else
                Msg.Text = "Dados inválidos"
            End If
        End If
    
    End Sub

</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
    <form runat="server">
        <h2>Login Page 
        </h2>
        <hr size="1" />
        <table>
            <tbody>
                <tr>
                    <td>
                        Username:</td>
                    <td>
                        <asp:TextBox id="UserName" runat="server"></asp:TextBox>
                    </td>
                    <td>
                        <asp:RequiredFieldValidator id="Requiredfieldvalidator1" runat="server" ErrorMessage="*" Display="Static" ControlToValidate="UserName"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        Password:</td>
                    <td>
                        <asp:TextBox id="UserPass" runat="server" TextMode="Password"></asp:TextBox>
                    </td>
                    <td>
                        <asp:RequiredFieldValidator id="Requiredfieldvalidator2" runat="server" ErrorMessage="*" Display="Static" ControlToValidate="UserPass"></asp:RequiredFieldValidator>
                    </td>
                </tr>
            </tbody>
        </table>
        <asp:button id="LoginBtn" onclick="LoginBtn_Click" runat="server" text="Login"></asp:button>
        <p>
            <asp:Label id="Msg" runat="server" ForeColor="red"></asp:Label>
        </p>
    </form>
</body>
</html>

t+

#2 wozniak

wozniak

    Hands-On Founder

  • Usuários
  • 578 posts
  • Sexo:Masculino
  • Localidade:Rio de Janeiro / RJ

Posted 10/12/2003, 09:54

página de logout:

<%@ Page Language="VB" %>
<script runat="server">

    Sub Page_Load(Sender As Object, E As EventArgs)
    
        If (Request.IsAuthenticated = true) Then
            Status.Text = "User " & User.Identity.Name & " is currently logged in."
        End If
    
    End Sub
    
    Sub LogOffBtn_Click(Sender As Object, E As EventArgs)
    
        FormsAuthentication.SignOut()
        Status.Text = "Not authenticated."
    
    End Sub

</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
    <form id="Form1" runat="server">
        <h2>Log Off Page 
        </h2>
        <hr size="1" />
        <p>
            Status: 
            <asp:Label id="Status" runat="server" ForeColor="red"></asp:Label>
        </p>
        <asp:button id="LogOffBtn" onclick="LogOffBtn_Click" runat="server" text="Log Off"></asp:button>
    </form>
</body>
</html>

t+




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq