EW Resource

Log In Example 2: Code

If you want to use this or explore it further yourself, copy the code below into a blank new page in EW. To do this, open a new page, go to code view, select all the code and then paste this code over it. Save it as a .aspx page. Back to the Log In examples

  <!DOCTYPE html>
<%@ Page Language="VB" %>
<html dir="ltr">
<head runat="server">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<style type="text/css">
body {
background-color: silver;
<script type="text/vb" runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    If Session("bolAuthenticated") = true Then
        pnlContent.Visible = True
        pnlLogin.Visible = False
        If IsPostBack Then
            If txtPass.Text = "mypassword" Then
                pnlContent.Visible = True
                pnlLogin.Visible = False
                Session("bolAuthenticated") = true
                lblMsg.Text = "The password was not recognised"
                lblMsg.Visible = True
            End If
        End If
    End If

End Sub
<title>Main page content</title>
<form id="form1" runat="server">

<asp:Panel ID="pnlLogin" runat="server">
<p><asp:TextBox ID="txtPass" runat="server" TextMode="Password" Required="required"></asp:TextBox> &nbsp;<asp:Button ID="btnEnter" runat="server" Text="Log In" /></p>
<p><asp:Label ID="lblMsg" runat="server" Visible="false"></asp:Label></p>

<asp:Panel ID="pnlContent" runat="server" Visible="false">
<h2>Main page content</h2>
<p>Example 2. You have logged in</p>
<p>Back to <a href="login-example1.aspx">Example 1</a>, where you will need to log in again.</p>
</div> /> </form>