You must create a page named (Starting a web site) Login.aspx in
You must create a page named Login.aspx in your site s root folder before you can actually use the controls described in this section. Otherwise, when you try to test the control in a Web browser, you ll get an error message indicating that the Login.aspx page cannot be found. The LoginStatus control The easiest way to provide a Login/Logout link is to drag a LoginStatus control to a Master Page. That s all you really have to do, besides close and save the Master Page. Then, right-click any page that uses the Master Page and choose View in Browser. In the browser, clicking the Login link should take you to Login. aspx. If you enter a valid user name and password, as in Figure 7-11, and click Log In, you ll be logged in. If your Default.aspx page uses the Master Page, you ll see that the link has changed from Login to Logout, because you re logged in. If you see a Logout link, click it to log out. You won t be taken to another page. You ll simply be logged out and the control will again show Login. Close the Web browser. If all of that works, you have all the basic stuff for a membership site: a way to sign up for an account, a way to log in, and site-wide Login and Logout links. Other stuff to follow in this section is optional stylistic stuff. By default, Logged Out users see a Login link, and authenticated users see a Logout link. In Design view, the LoginStatus control has all the usual design accoutrements, including a Properties sheet and Common Tasks menu (Figure 7-12). You can change the text of either link using the LoginText and LogoutText properties. As an alternative to using text links, you can choose a pair of graphic images to show. One image to show to anonymous users, and another to show to authenticated users. When those pictures are placed in your site s folders, use the LoginImageURL property of the control to specify the picture to show to anonymous users. Set the LogoutImageUrl to the picture that authenticated users should see. Figure 7-11: Putting Login. aspx to the test. Chapter 7: Working with ASP.NET Controls 137
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision servlet hosting services