Handling cookies in ASP .NET
How to create a cookie, how to get the value stored in a cookie, set the lifetime, path and domain for a cookie, edit a cookie, delete a cookie, remove subkeys Here’s a tutorial that shows you how to use cookies in ASP .NET. I’m not going to explain the role of cookies in web applications or cover any other theoretical aspect of cookies. There are many (similar) ways to handle cookies in ASP .NETshow you one of the ways, my way. Oh, and we’re going to use C#, although the code can be adapted to Visual Basic .NET easily.
Read more
ASP.NET 2.0 Just Do It!
Most books (especially about .NET, it seems) give you lots of concepts and theories and detailed, boring analysis before they ever let you jump in and play with the stuff. Don’t expect that here, though; I turn the traditional philosophy of chapter-order sequence on its head. In this book, I start by getting your server and development environment configured and set up so that you can create your first ASP.NET page in this chapter. There’s no teacher like experience!
Read more
Forms Authentication, Authorization, User Accounts, and Roles Security Basics and ASP.NET Support
What is the one thing forums, eCommerce sites, online email websites, portal websites, and social network sites all have in common? They all offer user accounts. Sites that offer user accounts must provide a number of services. At a minimum, new visitors need to be able to create an account and returning visitors must be able to log in. Such web applications can make decisions based on the logged in user: some pages or actions might be restricted to only logged in users, or to a certain subset of users; other pages might show information specific to the logged in user, or might show more or less information, depending on what user is viewing the page.
Read more
Working with Data in ASP.NET 2.0 - Handling BLL and DALLevel Exceptions
In the Overview of Editing and Deleting Data in the DataList tutorial, we created a DataList that offered simple editing and deleting capabilities. While fully functional, it was hardly userfriendly, as any error that occurred during the editing or deleting process resulted in an unhandled exception. For example, omitting the product’s name or, when editing a product, entering a price value of “Very affordable!”, throws an exception. Since this exception is not caught in code, it bubbles up to the ASP.NET runtime, which then displays the exception’s details in the web page. As we saw in the Handling BLLand DALLevel Exceptions in an ASP.NET Page tutorial, if an exception is raised from the depths of the Business Logic or Data Access Layers, the exception details are returned to the ObjectDataSource and then to the GridView. We saw how to gracefully handle these exceptions by creating Updated or RowUpdated event handlers for the ObjectDataSource or GridView, checking for an exception, and then indicating that the exception was handled.
Read more
Working with Data in ASP.NET 2.0 Displaying Data with the DataList and Repeater Controls
In all of the examples throughout the past 28 tutorials, if we needed to display multiple records from a data source we turned to the GridView control. The GridView renders a row for each record in the data source, displaying the record’s data fields in columns. While the GridView makes it a snap to display, page through, sort, edit, and delete data, its appearance is a bit boxy. Moreover, the markup responsible for the GridView’s structure is fixed - it includes an HTML with a table row () for each record and a table cell () for each field. To provide a greater degree of customization in the appearance and rendered markup when displaying multiple records, ASP.NET 2.0 offers the DataList and Repeater controls (both of which were also available in ASP.NET version 1.x). The DataList and Repeater controls render their content using templates rather than BoundFields, CheckBoxFields, ButtonFields, and so on. Like the GridView, the DataList renders as an HTML , but allows for multiple data source records to be displayed per table row. The Repeater, on the other hand, renders no additional markup than what you explicitly specify, and is an ideal candidate when you need precise control over the markup emitted.
Read more