Localizing client side JavaScript

Posted by: Imar Spaanjaars at Tuesday, February 24, 2009 9:34:02 AM in: ASP.NET 3.5

As you may know, my Contact Manager application used in my new series on N-Layer design using ASP.NET 3.5 is fully localizable. That is, the site is available in two languages - English and Dutch - and users can choose the language they want to see the site in. The concepts behind the localization process are all built in to the ASP.NET framework and didn't require a lot of work from my side.

Shortly after I published the article on localization, I received an e-mail from a reader asking how he could use the same principles to translate client side JavaScript. He had written some custom JavaScript code that displayed messages to the user and he wanted an easy way to translate those messages as well. The good news is: it's pretty easy to do....

Read on ...

N-Layered Web Applications with ASP.NET 3.5 Part 5: Dealing with Concurrency

Posted by: Imar Spaanjaars at Tuesday, February 10, 2009 9:40:00 PM in: ASP.NET 3.5

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.

Note: this is part five 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 five 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 discuss techniques for dealing with concurrency — I'll show you how to handle data conflicts caused by updates from other users.

Read on ...

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

Posted by: Imar Spaanjaars at Tuesday, January 20, 2009 8:04:08 PM in: ASP.NET 3.5

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 ...

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

Posted by: Imar Spaanjaars at Saturday, January 03, 2009 10:28:08 AM in: ASP.NET 3.5

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 ...

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

Posted by: Imar Spaanjaars at Sunday, December 14, 2008 7:28:08 PM in: ASP.NET 3.5

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 ...

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

Posted by: Imar Spaanjaars at Tuesday, November 25, 2008 10:46:00 PM in: ASP.NET 3.5

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 ...

Creating ASP.NET Users Programmatically

Posted by: Imar Spaanjaars at Sunday, September 28, 2008 5:52:51 PM in: ASP.NET 3.5
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 ...

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

Posted by: Imar Spaanjaars at Tuesday, September 16, 2008 6:42:24 PM in: ASP.NET 3.5
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 ...

Protecting Sections of your Web.Config File

Posted by: Imar Spaanjaars at Saturday, September 13, 2008 12:26:02 PM in: ASP.NET 3.5

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 ...

Watch Out When Setting the ID of a Master Page Dynamically

Posted by: Imar Spaanjaars at Sunday, September 07, 2008 11:11:42 AM in: ASP.NET 3.5

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 ... 123