Image representing the Articles category

N-Layered Web Applications with ASP.NET 3.5 Part 4: Sorting, Paging and Filtering

Published 15 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 02/03/2009: There is now a VB.NET version of the application available thanks to Sven Huijbrechts from ClearMedia bvba. Check it out at the Downloads section at the end of this article

Note: this is part four in a series of six. If you rather read this entire series off-line, you can buy the series as a convenient PDF document that comes with the full source. Besides the convenience, buying the PDF will also make you feel good as it shows your appreciation for the articles and helps me pay the bills for my server and hosting so I can keep running imar.spaanjaars.com and continue to provide you with great content. For more details, check out this post that shows you how you can buy the entire series right now.

This is part 4 of a six-part series of articles on N-Layer design. This article series builds on top of my three part series on N-Layer design that I released in early 2007. If you haven’t already done so, be sure to check out these articles first, as a lot of code and concepts used in this new series is explained in detail in the older series.

In this installment you'll see a few important ways to work with data: Sorting, Paging and Filtering.

Read on ...
Image representing the Articles category

N-Layered Web Applications with ASP.NET 3.5 Part 3: Advanced Validation Topics

Published 15 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 02/03/2009: There is now a VB.NET version of the application available thanks to Sven Huijbrechts from ClearMedia bvba. Check it out at the Downloads section at the end of this article

Note: this is part three in a series of six. If you rather read this entire series off-line, you can buy the series as a convenient PDF document that comes with the full source. Besides the convenience, buying the PDF will also make you feel good as it shows your appreciation for the articles and helps me pay the bills for my server and hosting so I can keep running imar.spaanjaars.com and continue to provide you with great content. For more details, check out this post that shows you how you can buy the entire series right now.

This is part 3 of a six-part series of articles on N-Layer design. This article series builds on top of my three part series on N-Layer design that I released in early 2007. If you haven’t already done so, be sure to check out these articles first, as a lot of code and concepts used in this new series is explained in detail in the older series.

In this installment I'll dig deeper into the Validation Framework I introduced in part 2 and show you how to write your own validation behavior in your business entities and how to set up your application for localization so you can target users in multiple languages.

Read on ...
Image representing the Articles category

N-Layered Web Applications with ASP.NET 3.5 Part 2: Introducing the Validation Framework

Published 15 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 02/03/2009: There is now a VB.NET version of the application available thanks to Sven Huijbrechts from ClearMedia bvba. Check it out at the Downloads section at the end of this article

Note: this is part two in a series of six. If you rather read this entire series off-line, you can buy the series as a convenient PDF document that comes with the full source. Besides the convenience, buying the PDF will also make you feel good as it shows your appreciation for the articles and helps me pay the bills for my server and hosting so I can keep running imar.spaanjaars.com and continue to provide you with great content. For more details, check out this post that shows you how you can buy the entire series right now.

This is part 2 of a six-part series of articles on N-Layer design using ASP.NET 3.5. This article series builds on top of my article series on N-Layer design that I released in early 2007. If you haven’t already done so, be sure to check out these articles first, as a lot of code and concepts used in this new series is explained in detail in the older series.

This installment and the next one deal with validation and show you how to implement a Validation Framework into your application in order to stop unwanted data from getting into your database.

Read on ...
Image representing the Articles category

N-Layered Web Applications with ASP.NET 3.5 Part 1: General Introduction

Published 15 years ago

Update 09/06/2013: I have written a completely new series targeting (ASP).NET 4.5 and Entity Framework Code First version 5. Check out the new series here: http://imar.spaanjaars.com/573/aspnet-n-layered-applications-introduction-part-1.

Update 02/03/2009: There is now a VB.NET version of the application available thanks to Sven Huijbrechts from ClearMedia bvba. Check it out at the Downloads section at the end of this article

Note: this is part one in a series of six. If you rather read this entire series off-line, you can buy the series as a convenient PDF document that comes with the full source. Besides the convenience, buying the PDF will also make you feel good as it shows your appreciation for the articles and helps me pay the bills for my server and hosting so I can keep running imar.spaanjaars.com and continue to provide you with great content. For more details, check out this post that shows you how you can buy the entire series right now.

In January 2007 I released the first part of a highly popular three-part article series on N-Layer design using ASP.NET. This article was followed by two more parts in February, and I updated all three articles in April to fix some minor issues in the code and in the articles. In June 2007 I added another – small – article to the series that showed you how to do custom sorting in N-Layer applications.

Now, almost two years later, it’s time for a major update on the articles and the Contact Manager Application that is discussed in the article.

Over the next six articles, I’ll show you how I improved the design of the original application, making it more powerful, secure and easier to maintain.

This is part 1 in the series. It builds on top of the earlier three part series on N-Layer design. If you haven’t already done so, be sure to check out these articles first, as a lot of code and concepts used in this new series is explained in detail in the older series.

Read on ...
Image representing the Articles category

Creating ASP.NET Users Programmatically

Published 15 years ago

One area in ASP.NET I see a lot of developers struggle with it deploying their sites. Compiling the application and then FTP-ing your files to a remote host is pretty easy. Then you need to set up a database. Often this is done by your ISP so you don't have to worry about that a lot either. But then you need to move your initial data from your development system to the remote server. By using the Database Publishing Wizard - now an integral part of Visual Studio 2008 - this is usually straight forward. You export the data to T-SQL Create and Update scripts and then execute those against the production database. While this works for most of your data, it doesn't always work correctly for the Membership and Roles data that is stored in your database. When it's not working, you typically do see your regular data in your application, but you can't seem to log in with the accounts you created on your local machine using the Web Site Administration Tool.

Read on ...
Image representing the Articles category

Storing Images as Serialized Strings in Code Instead of in Resource Files

Published 15 years ago

A colleague of mine and I were working on a template for My Generation the other day. (In case you didn't know, My Generation is a very cool Code Generation tool). One of the nice things about My Generation is that it allows you to use standard WinForms code to define the look and feel for the form where users can input their data (e.g. select the database, tables, specify output folders, language choice and so on). My colleague recently added a menu to this WinForm for often used commands to save and restore the form's state like Open, Save and so on. I thought it would be really fancy if the menus had a little menu icon as well. Normally, with .NET WinForms, adding such a menu icon is as simple as selecting a file. However, with My Generation templates, it's not so easy.

Read on ...
Image representing the Articles category

Protecting Sections of your Web.Config File

Published 15 years ago

I recently got a couple of e-mails from people asking why I was storing unencrypted data in my web.config files for applications as the ones used in my N-Layer design examples.

The main reason is: I don't have much to hide. First of all, the web.config doesn't contain a lot of sensitive information. For example, I use Integrated Security in my database connections, so I don't have a need for clear text passwords. Secondly, the config files are stored on my machine in a safe way as only the Administrators group and the accounts used by the web server can access them. Finally, IIS and ASP.NET work together to block users from downloading the web.config file. (To see what I mean, try downloading this file: http://imar.spaanjaars.com/web.config. The file really exists on disk, but you get a 404 Not Found error nonetheless.)

But of course, your mileage may vary. Maybe you're afraid your client changes things they shouldn't change in the web.config file. Or maybe some of your co-workers can access the server through FTP to update the site but you don't want them to be able to change the settings. Or maybe you're afraid an employee of your ISP can read your sensitive data when your site is hosted in a shared hosting environment. In those cases, it's good to know it's very easy to encrypt sections of the web.config file.

Read on ...
Image representing the Articles category

Watch Out When Setting the ID of a Master Page Dynamically

Published 15 years ago

It's not uncommon to set the ID of a Master Page in ASP.NET Programmatically. This is particularly useful when you have multiple master pages and want to have your CSS or JavaScript target specific control IDs in your code.

Without setting the ID property of the master page, a client side control ID may end up like this:

<input type="submit" name="ctl00$ContentPlaceHolder1$Button1" value="Button" 
id="ctl00_ContentPlaceHolder1_Button1" /> 

The ctl00 prefix on the id and name attributes represent the auto generated ID of the master page. Even if your page uses a different master, you may end up with the same prefix. Setting the server side ID of the master programmatically allows you to control the full control ID, making IDs predictable and thus more useable in client side code. For example, the following code in the code behind of the master page:

protected void Page_Init(object sender, EventArgs e)
{
  this.ID = "Master1";
}
will result in the following HTML for the same button control:
<input type="submit" name="Master1$ContentPlaceHolder1$Button1" value="Button" 
id="Master1_ContentPlaceHolder1_Button1" /> 

This way you can assign a predictable master ID that your client side CSS and script can use.

If you use this trick, you have to be aware of when exactly to set the ID. Do it too late and you'll get in troubles.

Read on ...
Image representing the Articles category

Spaanjaars.Toolkit.ContentRating: Version 1.1

Published 15 years ago

Ever since I wrote the initial version of my ContentRating control back in 2006, I received a massive amount of feedback, both as comments below the article and as private e-mails. Not surprisingly, if you consider the article has been read over 19,000 times and has been rated 444 times (at the time of writing).

Besides getting a lot of "thank you's" from people who liked the control, I also got a lot of requests for a real-world example of a test site using the control. The test site that shipped with the control used fake data stored in ViewState to simulate a real backing store which obviously didn't cut it for a lot of people.

Also, a reader called vgt pointed out a bug in the control where an existing cookie would be overwritten by a new one one, effectively allowing you to vote for the previous item again.

Finally, I had a few requests of my own: I didn't like the default data source of 5 integers if you didn't supply a data source yourself. I also didn't like it that the control didn't raise an exception when you tried to data bind it without a valid data source.

So, enough reasons to fire up Visual Studio and get my hands dirty on some control fixing.

Read on ...
Image representing the Articles category

Fun With Extension Methods - Extending Object Part 1

Published 15 years ago

Some time ago I was showing a colleague how to enhance an object's Design Time capabilities (or actually Debug Time) by adding a DebuggerDisplayAttribute. I blogged about this attribute earlier, so I won't go into it again now. But what I do want to talk about is the way the attribute gets its data.

Read on ...

Mobile: False

Crawler: True

I: False