login.aspx 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. <%@ Page Language="C#" EnableViewState="false" %>
  2. <%@ Import Namespace="System.Web.Security" %>
  3. <html>
  4. <script language="C#" runat=server>
  5. void Login_Click (object sender, EventArgs e)
  6. {
  7. Console.WriteLine("In Login_Click");
  8. if (IsPostBack == true && Page.IsValid)
  9. {
  10. Console.WriteLine("Before RedirectFromLoginPage: Name=" + name.Value);
  11. FormsAuthentication.RedirectFromLoginPage(name.Value, PersistCookie.Checked);
  12. }
  13. else
  14. Console.WriteLine("No IsPostBack or Page not valid");
  15. }
  16. </script>
  17. <head>
  18. <title>Login</title>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  20. </head>
  21. <body>
  22. <form method="POST" action="login.aspx" runat="server">
  23. <asp:ValidationSummary runat="server" HeaderText="Please fix the following errors:" />
  24. Name: <input type="text" id="name" runat=server/></td><td><ASP:RequiredFieldValidator ControlToValidate="name"
  25. Display="Static" ErrorMessage="Please enter a name" runat=server>*</ASP:RequiredFieldValidator>
  26. <p />
  27. Password:<asp:textbox id="password" textmode="password" runat="server" />
  28. <p />
  29. <ASP:CheckBox id=PersistCookie runat="server" checked="true" /> activate autologin
  30. <p />
  31. <asp:button text="Login" OnClick="Login_Click" runat=server/>
  32. </form>
  33. </body>
  34. </html>