Apr 25, 2008 at 8:01 PM
Edited Apr 25, 2008 at 8:03 PM
I'm working on a show case project that is a test web site, user tests to be specific.

I need one of those sites myself and it's simple enough to prove useful as a sample project.

I'm currently working with validations. I had switched from C# to ruby rails/merb for my web projects. But i'm switching back now when I got my fine own web server. =)

Validations are an important issue when it comes to web projects. Being able to validate input is crucial in most projects.

I've solved it by creating a class that encapsulates web forms. I'm going to add support for multiple languages soon (using culture settings for the current thread).

Current usage:

            TestCase testCase = new TestCase();
            Validator validator = new Validator(Request.Form["test"]);
            testCase.TestId = validator.Integer("id", Id, true);
            testCase.Name = validator.String("name", true);
            testCase.Category = validator.String("category", true);
            testCase.Description = validator.String("description", true);
            testCase.Created = DateTime.Now;
            // Dont do anything if validation failed.
            if (validator.Errors.Count > 0)
                return RenderErrors(validator, "add", "Id", Id, "IsAjax", Request.IsAjax);

The RenderErrors method checks if the request is made by ajax, then it uses the "alert" method to show errors (which results in that a message box is shown client side with the errors), otherwise it renders the errors in the page template.

Edit: Ohh. The sample also shows how to use my ORM layer. Fairly simple huh? ("DataManager.Create(testcase);" inserts a row into the database).