script languagec runatserver void

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ollowing a successful login LoginError Fired when an attempted login fails Validating Credential Formats <asp:Login ID="LoginControl" RunAt="server" OnLoggingIn="OnValidateCredentials" ... /> . . . <script language="C#" runat="server"> void OnValidateCredentials (Object sender, CancelEventArgs e) { if (!Regex.IsMatch (LoginControl.UserName, "[a-zA-Z0-9]{6,}") || !Regex.IsMatch (LoginControl.Password, "[a-zA-Z0-9]{8,}")) { LoginControl.InstructionText = "User names and passwords " + "must contain letters and numbers only and must be at " + "least 6 and 8 characters long, respectively"; e.Cancel = true; } } </script> 7 The LoginView Control Displays content differently to different users depending on: Whether user is authenticated If user is authenticated, the role memberships he or she is assigned Template-driven <AnonymousTemplate> <LoggedInTemplate> <RoleGroups> and <ContentTemplate> Using LoginView <asp:LoginView ID="LoginView1" Runat="server"> <AnonymousTemplate> <!-- Content seen by unauthenticated users --> </AnonymousTemplate> <LoggedInTemplate> <!-- Content seen by authenticated users --> </LoggedInTemplate> <RoleGroups> <asp:RoleGroup Roles="Administrators"> <ContentTemplate> <!-- Content seen by authenticated users who are administrators --> </ContentTemplate> </asp:RoleGroup> ... </RoleGroups> </asp:LoginView> 8 The LoginName Control Displays authenticated user names Use optional FormatString property to control format of output <asp:LoginView ID="LoginView1" Runat="server"> <AnonymousTemplate> You are not logged in </AnonymousTemplate> <LoggedInTemplate> <asp:LoginName ID="LoginName1" Runat="server" FormatString="You are logged in as {0}" /> </LoggedInTemplate> </asp:LoginView> The LoginStatus Control Displays links for logging in and out "Login" to unauthenticated users "Logout" to authenticated users UI and logout behavior are customizable <asp:LoginStatus ID="LoginStatus1" Runat="server" LogoutAction="Redirect" LogoutPageUrl="~/Default.aspx" /> 9 LoginStatus Properties Name Description LognText Text displayed for login link (default="Login") LogoutText Text displayed for logout link (default="Logout") LoginImageUrl URL of image used for login link LogoutAction Action to take following logout: Redirect, RedirectToLoginPage, or Refresh (default) LogOutPageUrl URL of page to go to following logout if LogoutAction="Redirect" Enabling the Role Manager Role manager is disabled by default Enable it via Web.config: <configuration> <system.web> <roleManager enabled="true" /> </system.web> </configuration> Set the Unobtrusive Validation Mode to None in Web.confi...
View Full Document

Ask a homework question - tutors are online