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.
Back to the Log In examples
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Page Language="VB" %>
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<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: #d9dac8;
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"></asp:TextBox>
<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> </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>