Archive for April, 2007

3. Type your return (Web design conference) e-mail address as the

Monday, April 30th, 2007

3. Type your return e-mail address as the From property. Figure 7-16 shows an example where I ve entered the hypothetical address support@yourdomain.com. 4. Optionally, you can also fill in the Subject line for the message. In addition to defining a return address, your site must be configured to use the SMTP (Simple Mail Transfer Protocol) server provided by your hosting service. You won t know what that is until you ve set up an account with a hosting provider, so don t knock yourself trying to get the PasswordRecovery control to work on your own PC. The PasswordRecovery control doesn t even need to work on your PC: It only has to work on the Web server. So the only smart thing to do is close and save the page that contains the PasswordRecovery control, and forget about it for now. If you try to test it in a Web browser, you ll just get an error message when it tries to e-mail the password. When you ve chosen a hosting provider, they will tell you how to configure your site to use their SMTP mail server. It may be something as simple as adding the following lines to your Web.config file: Figure 7-16: Set the From property to an address for your own domain. Chapter 7: Working with ASP.NET Controls 143
Note: In case you are looking for affordable webhost to host and run your web application check Vision cheap hosting services

the browser, the control first asks the user (Php web hosting)

Monday, April 30th, 2007

the browser, the control first asks the user to enter a user name and click Submit. If the user name exists in the database, the second page appears showing the user s secret question. When the user enters the correct answer and clicks Submit, the control e-mails a password to the user s e-mail address, and provides a Your password has been sent to you confirmation message. To use the control, create a new page or open the page on which you want to place the control. For my example I created a new page named Recover Password.aspx that uses my Master Page. Just drag the control onto the page, like any other server control. You can choose a color scheme from the Auto Format option on the control s Common Tasks menu. I applied the Classic scheme to the PasswordRecovery control shown in Figure 7-15. The PasswordRecovery tool is unique in that there are a couple of extra steps involved in getting it to work. Furthermore, the page has to be configured to work on the Web server, not your local PC, so you may need to just leave that page as-is, and then remember to finish it later after you ve copied the site to a Web server. One thing you need to configure is the return e-mail address. This will likely be an e-mail address you create using your own domain name (after you have set up your own domain name). You enter that return mailing address into the Properties sheet by following these steps: 1. With the page open and visible in Design view, click the PasswordRecovery control to select it. 2. In the Properties sheet, expand the Behavior and MailDefinition categories. Figure 7-15: The Password Recovery control. 142 Part II: Building Your Web Site
Note: If you are looking for high quality webhost to host and run your jsp application check Vision florida web design services

Letting Users Manage Passwords People forget their passwords (Kids web site)

Sunday, April 29th, 2007

Letting Users Manage Passwords People forget their passwords all the time. And the last thing you need is to be spending all your time reminding people of their forgotten passwords. So your site needs a means of allowing users to retrieve their own passwords. Likewise, users have to be able to change their own passwords, so your site will need that capability too. In the Login category of the Toolbox, the PasswordRecovery and ChangePassword controls are just the ticket. Using the PasswordRecovery control The PasswordRecovery control provides a way for a user to retrieve a forgotten password. (Actually, with the default hashed encryption used in Visual Web Developer, it sends them a new password that they can use to log on). In Drag Figure 7-14: LoggedIn Template contains text and Login Name and Login Status controls. Chapter 7: Working with ASP.NET Controls 141 Multiple views for multiple roles The LoginView control isn t limited to showing two different views. If your site contains numerous roles, you can use the Edit Role Groups option on the Common Tasks menu to define multiple views for multiple roles. In the RoleGroup Collection Editor, use the Add button to add a RoleGroup placeholder to the left column. Then, to the right of the Roles column in the right column type a valid role name from your site, and then click OK. You can repeat the process to add multiple role groups. After you ve created a RoleGroup, you can design what it shows to its members by clicking the Views option on the Common Tasks menu and choosing the new RoleGroup name. In other words, whatever you put in the Login View control at this point is visible only to people in the specified role.
Note: If you are looking for high quality webhost to host and run your jsp application check Vision florida web design services

So at this point, the Anonymous Template for (Make web site)

Sunday, April 29th, 2007

So at this point, the Anonymous Template for the LoginView control contains a Login link. If you click the Common Tasks button for the LoginView control, you should see AnonymousTemplate in the Common Tasks menu, and the Login link inside the LoginView1 control as shown in Figure 7-13. 5. To choose what authenticated users will see in the control, click the Common Tasks button for the LoginView1 control and choose LoggedInTemplate. The Login link disappears because it s on the Anonymous Template, not the LoggedIn Template. 6. In the LoginView1 control, type the word Hello followed by a blank space. 7. Drag a LoginName control from the Toolbox into the LoginView1 control, just to the right of the word Hello. 8. Drag a LoginStatus control from the Toolbox into the LogingView1 control. At this point, the LoggedInTemplate should look like Figure 7-14. When you view the Common Tasks menu for the LoginView1 control, it should show LoggedInTemplate, as shown in the figure. The LoginStatus control always shows the word Login in Design view. Don t worry about that. Later, when you actually use the page in a Web browser, it will show Logout to authenticated users. You can t open a Master Page on its own in a Web browser, so you can t choose View in Browser to test the page immediately. But that is not a problem. You ll be able to put things to the test a little later in this chapter. For now, just close and save the Master Page. Drag Figure 7-13: Login View control s Anonymous control contains a Login Status control. 140 Part II: Building Your Web Site
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision make web site services

After the control (Web hosting directory) is placed on the page,

Saturday, April 28th, 2007

After the control is placed on the page, the control is shaped as a box. The box has two different views, but you only see one view at a time. You can choose which view you want to see (and design) by choosing one of the following from the View option on the LoginView control s Common Tasks menu: Anonymous Template: Content that anonymous users see. LoggedIn Template: Content that only authenticated users see. What you put into either template is entirely up to you. It can be text, a table, a picture, an ASP.NET control, whatever. Think of the box as a mini-page that can contain anything that a big page can contain. During this stage of the site-building project, your best bet would be to create a simple LoginView control that shows a Login link to anonymous users. For authenticated users, the control shows the user s name and a Logout link. This comes in very handy when you re testing your site, because you can always see whether you re currently testing as an anonymous user or as an authenticated user. Putting the control on a Master Page is especially helpful because you ll be able to see it on every page that uses the Master. So, given that general advice, let s take a look at the steps required to make it happen: 1. In Solution Explorer, double-click your Master Page to open it in Design view. In Chapter 4, I created a MasterPage.master file in a folder named Masters. So I ll use that one as a working example here. 2. Drag a LoginView control from the Login category of the Toolbox to the top (or left) pane of the Master Page so that it will be visible on all pages that use the master. By default, the control will be named LoginView1. 3. From the control s Common Tasks menu, choose Anonymous Template. Whatever you add to the LoginView control now will be visible only to anonymous users. 4. Drag a LoginStatus control from the Toolbox into the LoginView1 control. The LoginStatus control appears as a Login link, and its Common Tasks menu might open automatically. You don t need to change anything on the LoginStatus control, so just click the larger LoginView1 control to hide that Common Tasks menu. Chapter 7: Working with ASP.NET Controls 139
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check Vision professional web hosting services

My web site - The Views menu on the LoginStatus control s Common

Saturday, April 28th, 2007

The Views menu on the LoginStatus control s Common Tasks menu lets you switch between what anonymous (Logged Out) users will see, and what authenticated (Logged In) users will see. You can change the text of either link just by editing the text. If you want something a little fancier than what the LoginStatus control has to offer, consider the LoginName and LoginView controls, discussed in the next two sections. The LoginName control The LoginName control is about as easy to use as a control can be. It shows nothing to anonymous users. For authenticated users, the control displays the user s login name. Typically you use the LoginName control with the LoginView control. The LoginView control Like the LoginStatus control, the LoginView control can tell the difference between anonymous and authenticated users. But it s not limited to showing text or a picture. You can use it to show just about anything, even ASP.NET server controls. To use the control, just drag it to the Web page or Master Page. Figure 7-12: Login Status control Common Tasks and Properties. 138 Part II: Building Your Web Site
Note: If you are looking for reliable webhost to maintain and run your java application check Vision java hosting services

You must create a page named (Starting a web site) Login.aspx in

Friday, April 27th, 2007

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

To align text in a table cell, right-click (Web hosting service)

Friday, April 27th, 2007

To align text in a table cell, right-click the cell and choose Style. Click Text in the Style Builder, set the Horizontal and Vertical Alignment, and click OK. To widen a column beyond what you can do by dragging, right-click some empty space in a cell in the column and choose Resize . Resize Column. Then, increase the current width, choose All Cells, and click OK. Like all ASP.NET controls, the Login control has a Common Tasks menu, as you saw earlier in this chapter. However, everything there is optional. All you really have to do is close and save the page on which you placed the control. To test the login page, right-click its name Login.aspx in Solution Explorer and choose View in Browser. To verify that the control works, type in a valid user name and password. An invalid user name and password is rejected. A valid entry takes you to the default page for the site. But that s fine for now; there s no way to verify right now if you re logged in or not anyway. This brings me to some other Login controls. (Don t forget to close the Web browser.) Providing a Login Link There s no telling which page in your site a user might first encounter. A link from a search engine could take a user to any page. To make your site easy to use, you need a login link on every page. An easy way to provide this is to put a link to the Login.aspx page into the Master Page for your site. But a regular link that always showed Login would be confusing for people who have already logged in. The link should show Logout or something else for people who are already logged in. That s where the LoginStatus control comes in. Figure 7-10: Login control added to a page. 136 Part II: Building Your Web Site
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision servlet hosting services

To verify that the process worked, you can (Hosting web)

Friday, April 27th, 2007

To verify that the process worked, you can choose Website . ASP.NET Configuration from the menu bar to open the Web Site Administration Tool. Click the Security tab, and then click Manage Users. The new user should be listed. If you added code to add the user to a role, click the Edit Roles link for that user. The check box should be filled already, indicating that the user is in the role. When you have a way for users to create an account on your site, the next thing they need is a way to log in with their user names and passwords. That s where the Login control comes into play. Creating a Login Page People who have already created accounts at your site need a place to sign in. Some of the other Login controls assume that page is in the site s root folder and named Login.aspx. So if you haven t already done so, you should create that page now by following the usual steps: 1. In Solution Explorer, right-click the site folder at the top of the folder hierarchy and choose Add New Item. 2. In the Add New Item dialog box, choose Web Form. 3. Name the page Login.aspx. 4. Choose C# as the language and choose Place Code In Separate File. Whether or not you choose to use a Master Page is entirely up to you. 5. Click the Add button. If you opted to use a Master Page, click the Master Page s folder, and then click the Master Page filename and click OK. I created my Login page using a table with two rows and two columns, and typed in a couple column headings as described in Chapter 5. I dragged the Login control from the Toolbox into the lower-right cell. I used its Common Tasks menu to apply the Classic scheme. Figure 7-10 shows the Login tool (highlighted in the Toolbox) and a Login control placed under the Already a Member? heading in a table. In the cell to the left of the Login control, I typed the Sign Up Now! text and selected it. Then I used the Convert to Hyperlink button in the toolbar to browse to the CreateAcct.aspx page I created previously. (In the Hyperlink dialog box, the Type appears as (other) and the URL as the name of the page.) Click OK, and the page offers non-members a way to create an account right now. Chapter 7: Working with ASP.NET Controls 135
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision best web hosting services

Testing the control After (Apache web server tutorial) you close and save

Thursday, April 26th, 2007

Testing the control After you close and save the new page, you can take the CreateUserWizard control for a test drive. Just right-click the page s name (CreateAcct.aspx in my example) in Solution Explorer, and choose View in Browser. When the page opens, you should be able to create a new user account You ll have to remember the user name and password to test the account later. Figure 7-9 shows an example of a user account (in the Web browser) with the user name Testy. The hypothetical data you enter needs to be realistic enough to pass all the tests that the control imposes. For example, if the passwords don t match, you ll get an error message in the control and won t be able to create the account. Don t forget that your password needs to be at least seven characters long, and must include a non-alphanumeric character. For example, password! (with the exclamation point) is an acceptable (if rather obvious) choice. When the control contains reasonable data for a hypothetical user account, click the Create User button. You should see a Your account has been successfully created message and a Continue button. At this point there s no place to continue to, so you can just close the Web browser to return to VWD. Figure 7-9: Create User Wizard control in the Web browser. 134 Part II: Building Your Web Site A coupla CreateUserWizard tips If you take a look at the whole Properties sheet for the CreateUserWizard control, you ll see it has many properties. You can figure out what most properties are just by looking at their names and values. A couple of noteworthy properties include ContinueDestinationPageURL and Login CreatedUser. You can set the Continue DestinationPageURL property to whatever page you want to have open when the user clicks Continue after successfully creating an account. The LoginCreatedUser property determines whether or not the user is logged in automatically after creating the account. The default is True, the user is logged in.
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision servlet hosting services