<html>
<head>
<script language = "C#" runat=server>
void SubmitBtn_Click ( Object Source, EventArgs E ) {
// pull credentials from form fields and try to authenticate.
if ( FormsAuthentication.Authenticate ( UserName.Value, UserPassword.Value ) ) {
FormsAuthenticationTicket ticket = new
FormsAuthenticationTicket ( UserName.Value, false, 5000 );
FormsAuthentication.RedirectFromLoginPage ( UserName.Value,
PersistForms.Checked );
}
}
</script>
</head>
<body>
<form method=post runat=server>
<table>
<tr>
<td>Name:</td>
<td><input type = "text" id = "UserName" runat=server/>
</tr>
<tr>
<td>Password:</td>
<td><input type = "password" id = "UserPassword" runat=server/>
</td>
</table>
<input type=checkbox id = "PersistForms" runat=server />Use persistent cookie
<br>
<input type = "submit" onServerClick = "SubmitBtn_Click" runat=server />
</form>
</body>
</html>
<html>
<head>
<script language = "VB" runat=server>
Sub SubmitBtn_Click ( Source As Object, E As EventArgs )
' pull credentials from form fields and try to authenticate.
If FormsAuthentication.Authenticate ( UserName.Value, UserPassword.Value ) Then
Dim ticket As New FormsAuthenticationTicket ( _
UserName.Value, false, 5000 )
FormsAuthentication.RedirectFromLoginPage _
( UserName.Value, PersistForms.Checked )
End If
End Sub
</script>
</head>
<body>
<form method=post runat=server>
<table>
<tr>
<td>Name:</td>
<td><input type = "text" id = "UserName" runat=server/>
</tr>
<tr>
<td>Password:</td>
<td><input type = "password" id = "UserPassword" runat=server/>
</td>
</table>
<input type=checkbox id = "PersistForms" runat=server />Use persistent cookie
<br>
<input type = "submit" onServerClick = "SubmitBtn_Click" runat=server />
</form>
</body>
</html> |