EW Resource

Log In Example 1: 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 is 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;
margin: 20px;
<script type="text/vb" runat="server">

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

    If IsPostBack Then
        If txtPass.Text = "mypassword" Then
            pnlContent.Visible = True
            pnlLogin.Visible = False
            lblMsg.Text = "The password was not recognised"
            lblMsg.Visible = True
        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 1. You have logged in</p>
<p>Back to <a href="login-example2.aspx">Example 2</a>. If you were logged in, you still will be.</p>