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 {
font-family:Verdana;
font-size:85%;
background-color: silver;
margin: 20px;
}
</style>
<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
        Else
            lblMsg.Text = "The password was not recognised"
            lblMsg.Visible = True
        End If

    End If

End Sub

</script>
<title>Main page content</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<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>
<asp:Panel ID="pnlContent" runat="server" Visible="false">
<h2>Main page content</h2>
<p>Example 1. You have logged in</p>
<p>&nbsp;</p>
<p>Back to <a href="login-example2.aspx">Example 2</a>. If you were logged in, you still will be.</p>
</asp:Panel>
</div>
</form>
</body>
</html>