-
30 September 2008
Three C# 2.0/3.0 Syntaxes That You Didn’t Know But Were Afraid to Ask
Working with other colleagues, I found these C# syntaxes are still not well-known and used, so I thought of blogging on them.
1 – Properties Without Members
In the old days, before C# 3.0, we used to write syntax like:
Tagged under: | 14 comments -
22 September 2008
The Three Steps of Building an ASP.NET Validator Control

The standard ASP.NET validator controls such as the
RequiredFieldValidatoror theRegularExpressionValidatordo not cover all validation requirements, so usually developers tend to create aCustomValidatorfor such scenarios.A major problem with the
CustomValidatoris reusability, as if you wanted to use the validator in another project then there would be some copying and pasting and code duplication, then you have to maintain multiple versions of the same control.The solution, as you have guessed from the title, is to build your own validator control when possible to promote reusability.
In this post I will be showing you in three simple steps how to build an ASP.NET validator control and take credit card number format check to show by example. I will also be building the architecture so that your validator and other validators that you will develop in the future could be as reusable as possible.
How to Check a Credit Card Format
Luhn check is an algorithm that checks if a credit card number is valid (format wise), so in practice, before you even think of doing any further processing on the credit card, this check should be satisfied.
Tagged under: | 7 comments -
23 August 2008
LINQ to SQL: The Data Access Layer (DAL) Shrinker

In the pre-LINQ days, I used to use the classical 3-tiers architecture for designing ASP.NET web projects, the user interface (UI), the business logic layer (BLL) and the data access layer (DAL).
My DAL layer used to rely on Microsoft’s Data Access Application Block (DAAB) which abstracted the repetitive and boring ADO.NET implementations. There are some 3rd party tools such as SubSonic, which has some common features with LINQ, or NHibernate, however, I would rather use the enterprise library.
Let me quickly illustrate the way to solve a problem with the classical architecture. This is a simple business problem, a website that has many brands and each brand has an advertising campaign. To access the campaign stats, which are supplied by the campaign agency, we need to access the agency’s webservice by providing our brand credentials. We simply store these login credentials in our database -> retrieve login info of a brand -> call the webservice -> display the stats on a web page.
Tagged under: | 2 comments -
22 March 2008
How to HTTP Post in .NET and handle the 500 errors
If you google you will find a lot of posts that will tell you how to HTTP post (some call it HTML post) in .NET. However, they all fail, or at least the ones I found, to tell you how to handle the returned 500 errors and retrieve the message behind it.
I have been posting to a service and getting the “500 Internal Server Error” which doesn’t tell much! I had done some research to get the real error behind it. Here is my code snippet in C#:
Tagged under: | 1 comment -
15 February 2008
Check Validator – An ASP.NET Validator Control

While some developers assume that the classical ASP.NET validators support check boxes and radio buttons, this isn’t the case! There is a logical explanation for this; there is nothing much to check, the checkbox can only be checked or unchecked so what do you want to validate?
In some cases you might want to display an error if a check box or a radio button is unchecked, e.g. terms and conditions check box, if so, then this is the right validator for you. Read on if you are interested in the bits and pieces of how the control works or skip to the “Using The Validator” section if you are just interested in using it.
Tagged under: | 11 comments
-
Recent Posts
-
Tags Cloud
© Copyright 2007 - 2010, all rights reserved for Adam Tibi
top