1 / 24

ASP.NET

ASP.NET. The Clock Project. The ASP.NET Clock Project. The ASP.NET Clock Project is the topic of Chapter 23 . By completing the clock project, you will learn your way around Visual Studio .NET.

jfillmore
Download Presentation

ASP.NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ASP.NET The Clock Project

  2. The ASP.NET Clock Project • The ASP.NET Clock Project is the topic of Chapter 23. By completing the clock project, you will learn your way around Visual Studio .NET. • After launching the development environment for the first time, you will explore its windows and practice using controls that enable you to create, edit, run, and debug an application. • Let us work through the clock project together.

  3. Creating an ASP.NET Project • Put Visual Studio .NET on your Windows taskbar to start it up quickly. • Create a new project with Visual Studio .NET. • Understand what is meant by the term Web Form.

  4. The Clock Script • Create an ASP.NET page that tells the time. • In HTML view, we write the following code: • <h1>The Clock Strikes</h1> • The time is <% = DateTime.Now.ToLongTimeString() %>

  5. Running an ASP.NET Project • Use the start button to run a project. • Debug a project containing errors. • Understand how actions you take in Design View change the code in HTML View.

  6. Using the Toolbox • Open the toolbox and drag controls onto the design surface. • Modify properties of controls on the design surface. • Discover how the design surface uses absolute positioning to place objects on screen. • Illustrate this by creating an Update button.

  7. ASP.NET Top Secret ProjectPart 6: Goals and Objectives • The Top Secret Project is the topic of Part 6 of Advanced Web Design. • It enables you to look further under the hood of ASP.NET. • You learn how to create a database with Microsoft Access or SQL Server, populate the database with user names and passwords, and use ADO.NET to decide who can access your site.

  8. Top Secret ProjectChapter 24: Creating the Database • Chapter 24 gets you started by having you use either Microsoft Access or SQL Server to create the Top Secret database. • You make a Users table that will contain the names and passwords of your users. • You populate the database with a few users allowed to access your top secret stuff.

  9. Top Secret ProjectChapter 25: Listing the Users • In Chapter 25, you write an ASP.NET script that reads information from the Top Secret database and displays it in a listbox on a Web page. • The design process you follow in this chapter will teach you how to use a code-behind page to separate your programming from the Web page. • You will call upon the assistance of the Code Designer to help you create the code-behind page, on which you will write a little program that uses a data adapter to connect to a database. • After issuing an SQL query that fills a dataset with the names of your Top Secret users, you will read from the dataset and load into the listbox the name of each user permitted access to the Top Secret database.

  10. Top Secret ProjectChapter 26: Adding New Users • At the moment, if you want to add a user to the Top Secret database, you need to use your database software (i.e., Microsoft Access or SQL Server) to do so. • Suppose you are at a remote location, away from your server, and the need arises to add another user to the database. Wouldn’t it be nice to have a way to add new users remotely? • In Chapter 26, you will add to the Users.aspx Web page an Add User button that enables you to add new users remotely over the Web.

  11. Top Secret ProjectChapter 27: Updating Users • You need to update a database when information changes in a dataset. • Suppose one of your Top Secret users gets a new e-mail address, for example. • Changing that user’s e-mail address requires you to connect to the database, locate the user’s record, change the e-mail address in the dataset, and update the database. • In Chapter 27, you will learn how to make these kinds of changes in a database.

  12. Top Secret ProjectChapter 28: Deleting Users • In Chapter 28, you will create a Delete button that will enable you to remove users from the database who no longer should have access to your top secret information. • When you write the code for the Delete button, you will learn the dataset method for deleting records from a database. This will round out the database functions you have learned in this part of this book. • By the time you complete this chapter, you will have learned how to insert, update, retrieve, and delete records from a database.

  13. Top Secret ProjectChapter 29: Logging Users In • Authentication is the process of determining whether a user should be permitted or denied access to a resource such as a Web site. On the Internet, Web sites that are not publicly accessible require users to log in to gain access. • In Chapter 29, you will create a login screen for the Top Secret project. The login screen will contain three controls: a text field into which the user will type a user name, a text field into which the user will type a password, and a login button. • When the user presses the login button, a script will gather the name and password from the login form and check to see whether the user should be permitted access. If so, the script will set an authentication cookie that will permit the user to access the Web site. If the name and password are not recognized, on the other hand, the user will be denied access to your top secret stuff.

  14. Top Secret ProjectChapter 26: Adding New Users • At the moment, if you want to add a user to the Top Secret database, you need to use your database software (i.e., Microsoft Access or SQL Server) to do so. • Suppose you are at a remote location, away from your server, and the need arises to add another user to the database. Wouldn’t it be nice to have a way to add new users remotely? • In Chapter 26, you will add to the Users.aspx Web page an Add User button that enables you to add new users remotely over the Web.

  15. Top Secret ProjectAdding a Button • To add a button to an ASP.NET page, follow these steps: • Drag a button from the WebForms toolbox to the design surface. • Edit the button’s properties to give it the text and ID you want it to have. • Double-click the button to make the code generator create its handler. • Write the script to handle the button.

  16. Top Secret ProjectAdd User Script • The add user script performs the following tasks: • Get the data from the form. • See if the user already exists. • Add the new user to the data table. • Update the database. • Display a feedback message

  17. Top Secret ProjectChapter 27: Updating Users • You need to update a database when information changes in a dataset. • Suppose one of your Top Secret users gets a new e-mail address, for example. • Changing that user’s e-mail address requires you to connect to the database, locate the user’s record, change the e-mail address in the dataset, and update the database. • In Chapter 27, you will learn how to make these kinds of changes in a database.

  18. Top Secret ProjectUpdate User Script • The update user script performs the following tasks: • Get the user name from the form. • Make sure the user name exists. • Update the fields in the data table. • Update the database. • Display a feedback message.

  19. Top Secret ProjectChapter 28: Deleting Users • In Chapter 28, you will create a Delete button that will enable you to remove users from the database who no longer should have access to your top secret information. • When you write the code for the Delete button, you will learn the dataset method for deleting records from a database. This will round out the database functions you have learned in this part of this book. • By the time you complete this chapter, you will have learned how to insert, update, retrieve, and delete records from a database.

  20. Top Secret ProjectDelete User Script • The delete user script performs the following tasks: • Get from the form the user name to be deleted. • Make sure the user exists. • Delete the user from the data table. • Update the database. • Display a feedback message

  21. Chapter 29: Logging Users In • Design the Login.aspx page, which contains four labels, two text fields, and one button . • Code and test the Login button. • Make the login button set the authentication cookie. • Configure the authentication mode in the Web.config file.

  22. Setting theAuthentication Cookie • To set the authentication cookie, make the code that handles the login button issue the following command if the username and password are valid: • System.Web.Security.FormsAuthentication.SetAuthCookie(sUserName, false); • False causes the cookie not to get written to the user’s hard drive.

  23. Configuring theAuthentication Mode • Open the project’s Web.config file. • Make the <authentication> section read as follows: • <authentication mode="Forms"> <forms loginUrl="login.aspx"></forms></authentication> • This causes unauthenticated users to get the login.aspx page if they try to access any other page in this app.

  24. Identifying the User • When a user has logged on, you can find out the user’s name via the following code: • String sUserName = "";if (HttpContext.Current.Request.IsAuthenticated) sUserName = HttpContext.Current.User.Identity.Name;

More Related