Custom Sorting with N-Layer Design Classes and the GridView
Published 17 years ago
Over the past couple of months I received a number of questions related to sorting with the classes from my N-Layer Design article series and the GridView. The good thing is: it isn't that hard; it's just that you need to know how to do it....
Read on ...Building Layered Web Applications with Microsoft ASP.NET 2.0 - Part 3
Published 17 years ago
Update!! - I have written a new series on N-Layer design targeting ASP.NET 4.5 and Entity Framework 5. You can check out the new series here.
Update!! 12-24-2008 - I have written a new series on N-Layer design as a major follow up to this one. It builds on the foundation created in this first series, but digs much deeper into concepts like Validation, Sorting, Paging, Concurrency and Security. You can check out the new series here.
Update!! 04-25-2007 - There is now also a VB.NET version of the code available for download. You find the download at the end of this article. For more information about the translation, check out this blog post.
This is part three of the article series "Building Layered Web Applications" that shows you how to build N-Layer applications with Microsoft ASP.NET 2.0. These articles teach you how to design, build and use custom business objects in your web application. The target audience for this series are developers that are ready to make the switch from using SqlDataSource controls to ObjectDataSource controls with custom business objects. Experience with ASP.NET 2 and C# is necessary while some knowledge about object oriented design certainly helps.
Part one dealt with the design of the application: what business objects do you need to fulfill the requirements of the application. What should these objects be capable of and how do they look. How do these business objects interact with other parts of the system? Part two showed you how to code the classes that were designed in part one. You saw how to implement the data access methods and database code and how the various classes were able to work together. You also saw how to use the API to programmatically create contact persons and their contact data and save those in a database. However, writing explicit code to work with your business objects isn't always fun, and can be a cumbersome task.
Therefore, this article (part three) deals with using the business objects in a web application. You'll see how to use the ASP.NET controls like the GridView in conjunction with the business objects. You'll see how you can build pages that allow you to list, create, edit and delete your contact persons and their contact data, like e-mail addresses and phone numbers.
If you haven't read part one or two yet, you should really read them first, as this article uses many concepts that have been explained in part one and two. The entire series (including this current article) can be found here:
- Building Layered Web Applications with Microsoft ASP.NET 2.0 - Part 1
- Building Layered Web Applications with Microsoft ASP.NET 2.0 - Part 2
- Building Layered Web Applications with Microsoft ASP.NET 2.0 - Part 3
The article uses a SQL Server 2005 Express database which is easy to use in development scenarios. However, the downloads for this series also come with the T-SQL scripts to recreate the database in SQL Server 2000 or SQL Server 2005. You'll find the download link at the end of this article. Besides the forementioned SQL scripts and database, the download also contains the full source for the demo application in C#.
Read on ...Building Layered Web Applications with Microsoft ASP.NET 2.0 - Part 2
Published 17 years ago
Update!! - I have written a new series on N-Layer design targeting ASP.NET 4.5 and Entity Framework 5. You can check out the new series here.
Update!! 12-24-2008 - I have written a new series on N-Layer design as a major follow up to this one. It builds on the foundation created in this first series, but digs much deeper into concepts like Validation, Sorting, Paging, Concurrency and Security. You can check out the new series here.
Update!! 04-25-2007 - There is now also a VB.NET version of the code available for download. You find the download at the end of this article. For more information about the translation, check out this blog post.
Update!! 04-24-2007 - Fixed a bug in the stored procedure that deletes a Contactperson, based on feedback from reader csharpdev. This also affects the downloadable code for this article, which now also has the update applied.
This is part two of the article series "Building Layered Web Applications" that shows you how to build N-Layer applications with Microsoft ASP.NET 2.0. These articles teach you how to design, build and use custom business objects in your web application. The target audience for this series are developers that are ready to make the switch from using SqlDataSource controls to ObjectDataSource controls with custom business objects. Experience with ASP.NET 2 and C# is necessary while some knowledge about object oriented design certainly helps. The design I am going to show you in these articles is a simplified version of a design you would use in a real world application. It doesn't feature all the necessary functionality your application needs, but instead focuses on the underlying concepts.
Part one dealt with the design of the application: what business objects do you need to fulfill the requirements of the application. What should these objects be capable of and how do they look. This article (part two) continues where the previous article stopped: it shows you how to code the classes that were designed in part one. You'll see how to implement the data access methods and database code and you'll learn how you can connect these classes. Part three then deals with using the business objects in a web application. You'll see how to make use of the out-of-the-box ASP.NET 2.0 controls together with the business objects coded in this part.
If you haven't read part one yet, you should really read it first, as this article uses many concepts that have been explained earlier. Afterwards, check out part three where you'll see the concepts from this article in an actual web site. The entire series (including this current article) can be found here:
- Building Layered Web Applications with Microsoft ASP.NET 2.0 - Part 1
- Building Layered Web Applications with Microsoft ASP.NET 2.0 - Part 2
- Building Layered Web Applications with Microsoft ASP.NET 2.0 - Part 3
The article uses a SQL Server 2005 Express database which is easy to use in development scenario's. However, the downloads for this series also come with the T-SQL scripts to recreate the database in SQL Server 2000 or SQL Server 2005. You'll find the download link at the end of this article. Besides the aforementioned SQL scripts and database, the download also contains the full source for the demo application in C#
Read on ...Measuring the Size of Uploaded Images
Published 17 years ago
In an earlier snippet I showed you how to measure the size of an image on disk. In a more recent post I explained how to work with an in-memory representation of an uploaded file and attach it to an e-mail message.
If you combine the two concepts you end up with a solution that allows you to check the dimensions of an uploaded file, so you can reject it if it doesn't have the correct dimensions before you save it to disk.
Read on ...Building Layered Web Applications with Microsoft ASP.NET 2.0 - Part 1
Published 17 years ago
Update!! - I have written a new series on N-Layer design targeting ASP.NET 4.5 and Entity Framework 5. You can check out the new series here.
Update!! 12-24-2008 - I have written a new series on N-Layer design as a major follow up to this one. It builds on the foundation created in this first series, but digs much deeper into concepts like Validation, Sorting, Paging, Concurrency and Security. You can check out the new series here.
Update!! 04-25-2007 - There is now also a VB.NET version of the code available for download. You find the download at the end of this article. For more information about the translation, check out this blog post.
This is part 1 of the article series "Building Layered Web Applications" that shows you how to build N-Layer applications with Microsoft ASP.NET 2.0. These articles teach you how to design, build and use custom business objects in your web application. The target audience for this series are developers that are ready to make the switch from using SqlDataSource controls to ObjectDataSource controls with custom business objects. Experience with ASP.NET 2 and C# is necessary while some knowledge about object oriented design certainly helps. The design I am going to show you in these articles is a simplified version of a design you would use in a real world application. It doesn't feature all the necessary functionality your application needs, but instead focuses on the underlying concepts.
What's important to realize is that this is *my* take at layered design for web applications. I won't say this is *the* design for the problem, or the only right one. In fact, I am sure some will judge this as "not the right one". However, it's a design that has worked for me in the past and still works today. It works best in many day-to-day small to medium sized web sites. You know, the kind of sites many of you (including myself) are building right now.
Part one deals with the design of the application: what business objects do you need to fulfill the requirements of the application? What should these objects be capable of and how do they look? How do these business objects interact with other parts of the system? Part two then shows you how to implement the code for these objects, while part three deals with using the business objects in a real-world web application.
The entire series (including this current article) can be found here:
- Building Layered Web Applications with Microsoft ASP.NET 2.0 - Part 1
- Building Layered Web Applications with Microsoft ASP.NET 2.0 - Part 2
- Building Layered Web Applications with Microsoft ASP.NET 2.0 - Part 3
The article uses a SQL Server 2005 Express database which is easy to use in development scenario's. However, the downloads for this series also come with the T-SQL scripts to recreate the database in SQL Server 2000 or SQL Server 2005. You'll find the download link at the end of this article. Besides the forementioned SQL scripts and database, the download also contains the full source for the demo application in C#.
Read on ...Storing Uploaded Files in a Database or in the File System with ASP.NET 2.0
Published 17 years ago
Update 2010/08/10: I just posted an article featuring a new version of this application based on the Provider Model design pattern. You can find the article here.
A common requirement in web sites is handling client files that are uploaded through the browser. Whether these files come from a protected Admin section where content managers can upload files, or from a public section doesn't matter; you need a way to retrieve and store these files in your system somewhere so they are available for viewers.
Allowing a user to upload a file is easy; just drop a FileUpload control on your page and .NET will handle the rest for you. However, it's after the file gets uploaded to the server where things get interesting. One of the things you have to take into account is where you're going to store the uploaded file. Two common places are the hard drive of your server and a database. There has been a lot of debate on the Internet about the best way to store your files. Some say the file system is the only acceptable option, while others really like the database solution.
In this article I'll show you how to store files both ways. I'll discuss the pros and cons of each solution, and show you the code you need to save your uploaded files. As a sample application, I'll build a small web site that allows you to upload files and store them at a location that you determine. You can decide where the files are stored through a simple setting in the web.config file. Depending on this setting, files are either stored directly at the hard drive of your server or in a database. You can even change this setting at run-time without affecting existing files.
Read on ...Using the ValidatorCallout control in Combination with ASP.NET 2 Templated Controls
Published 17 years ago
Now that the release date for the final version of ASP.NET AJAX 1.0 is getting closer (RC1 was released on December 14 2006), I decided to dig a little deeper in its feature set and see what it has to offer. I also looked at the ASP.NET AJAX Control Toolkit and the new controls that are part of this toolkit.
One of those new controls is the ValidatorCallout extender control that displays a big yellow call out with the error message.
Read on ...Changing the Login Control to Display a List of Users
Published 18 years ago
A while ago I saw this post on the P2P Wrox forum (near the middle of the thread) where the poster asked for a way to replace the standard TextBox in the asp:Login control with a list of user names from the system. He didn't mind the lowered security implications of this solution and instead wanted to make it a little easier for users to login. With his proposed solution, a user can pick a name from the list, enter a password and log in. I guess fewer things to remember means fewer calls to the helpdesk.
It turns out this is actually quite easy to do.
Read on ...Using the Microsoft Access Providers to Replace the Built-In SQL Server Providers
Published 18 years ago
Update 2011/1/9: I just published a short article that shows you how to use the Microsoft Access Providers in an ASP.NET 4 web site.
The biggest features brought by ASP.NET 2.0 are most likely the new services for membership, roles, personalization and profiles. These services supply you with a lot of functionality out-of-the-box with little to no custom code. The services that ship with .NET 2.0 all use SQL Server as the data store (either the Express edition, or the full commercial versions) by means of a provider. But what if you can't use SQL Server, for example because your hosting company doesn't support it? In that case, you can use the Microsoft Access Providers, a shared source initiative released by Microsoft that allows you to use a Microsoft Access database for all the provider based features.
This article shows you how to acquire, compile and use these Microsoft Access Providers.
Read on ...Building Smarter User Controls
Published 18 years ago
User Controls are very common in today's ASP.NET websites, both in version 1.x as in version 2.0. Many sites use them to reuse content, like a menu, a header or a footer or even for partial page content, like a shop's product catalog.
However, User Controls can be used for more than simply displaying static, repeating content. With a bit of knowledge about how User Controls work, you can teach them a few tricks. By adding public properties to a User Control, they become much more powerful and easier to reuse.
In this article I'll show you how to build a User Control that displays information about an article, like a news item, similar to the Details section that you find at the top of most pages in my site.
Although I am using Visual Studio 2005 and ASP.NET 2.0 in this article, the same principles and code work for Visual Studio .NET 2002 / 2003 and ASP.NET 1.x as well.
Read on ...Mobile: False
Crawler: True
I: False