Posts

An Asp.Net Validation Framework (Part 2)

Image
In the first part , we saw how to create custom attributes and rules. Now we'll look at how to implement those attributes. The IValidatable interface defines how consumers can interact with the framework. It indicates that we'll have a collection of BrokenRules and offers a method to perform validation. ValidatableBase implements IValidatable and does most of the work. Your classes simply inherit from ValidatableBase and they are completely functional. You decorate all of the properties you want. /// <summary> /// Interface for class that wish to implement /// validation. /// </summary> public interface IValidatable { /// <summary> /// Gets the collection of business rules that have /// been broken. /// </summary> BrokenRulesCollection BrokenRules { get; } /// <summary> /// Validates the objects. /// </summary> /// <param name="clearBrokenRules">Indicates if the Broken...

An Asp.Net Validation Framework

I've been working on different ways to implement a validation framework that would really cut down on the code. It  had to be reusable and testable. I also didn't want to swap writing one bunch of repetitive code for another. I'd looked at CSLA from Rockford Lhotka . I liked the way he implemented broken rules but CSLA had a lot of stuff for multiple undo's that was not relevant to my apps. I then used some of ScottGu's stuff for LINQ to SQL and begin using validation methods that threw exceptions. Reusable and custom exceptions made this very testable but I was still writing a bunch of repetitive code. Microsoft's Enterprise Library has a Validation Block that was interesting but really seemed to be overkill.  I did like the declarative nature though and then found this from Imar Spaanjaars . That was more what I was looking for and I could see where I could make some changes. First change was in the naming. NotNullOrEmptyAttribute became RequiredAtt...

VSS 2005 Web Interface

Image
Step 1: Create your database. Make sure you change the Admin password as it starts out blank. Step 2: Share the folder. For the share name I added a Vss so I'd know why it was shared. Step 3: Set your Security in Windows. Add each user and give them modify on the folder. Also, you may have a problem with inherited rights from the parent folder. That seemed to manifest itself as "Access to file...\data\rights.dat denied." Click on the Advanced button and tell it to update all child folders. I just got in the habit of doing this for all users. One of the things that kept biting me was forgetting to set the Permissions on the share. Click on the Permissions button and add all of the desired users. Make sure you remove Everyone.   Step 4: Check out Alin Constantin's page. He's got about 90% of the work done. Tips: If you're going to use a subdomain, have it created and ready to go. Wildcard certificates will work. Make sure that your Sour...

Object Expected error in IE for external Javascript file

Recently ran into one of those silly IE issues that can drive you nuts. I kept getting a JScript runtime error "Object expected" when I tried to call a recently added function in an external file. Funny, function works fine when in the main page. Other functions in the file worked fine. Lots of Google hits but they were all about streaming order. The answer is that IE has cached your js file and is not reading the current version. The easiest way to correct the issue is to press Ctrl-F5 on the page in IE. This causes IE to completely reload the page. BTW, this is during development in Visual Studio using the development server. I have a feeling that somehow IE is not seeing that the js file has changed. It may be that the dev server is not changing the date.

JavaScript function to automatically add slashes to date

In converting an old Windows app to a browser app, the user wanted to be able to enter dates without the slashes. Here's a simple jscript: 1: // Function to convert short date string (MMddyy) 2: // or (MMddyyyy) to a date string (mm/dd/yyyy). 3: // txtBox is the actual textbox control 4: // with the value to be processed. 5: function FixShortDate(txtBox) { 6: if (txtBox == null ) { 7: return '' } 8:   9: var re = new RegExp(/(\d{6})(\d{2})?/); 10:   11: if (re.test(txtBox.value)) 12: { 13: if (txtBox.value.length == 8) { 14: txtBox.value = txtBox.value.substring(0, 2) + '/' + txtBox.value.substring(2, 4) + '/' + txtBox.value.substring(4, 8) 15: } 16: 17: if (txtBox.value.length == 6) { 18: if (txtB...

Kurt Warner belongs in the Hall of Fame

Kurt Warner is the definition of a Hall of Famer. Why? Every time someone said quit, he kept fighting. He took what was given to him and made the best of it. Along the way he got a Superbowl ring, Superbowl MVP honors, season MVP honors and is one of the most dangerous QB's in the game. The greatest show on turf was not a fluke. Probably the biggest single thing for me is a veteran player who says "I need to improve myself, fix what needs fixing and then I can lead my team". Kurt has done that. Improvements in reading receivers and how he holds the ball. There's not much more a coach can ask player to do. Oh, by the way his character has been impeccable. A selfless player who works in the community for the benefit of others. Yes, character should count for HoF. We need more guys like Kurt and Tony Dungy. Christian men who are not afraid to stand up and be counted. BTW, please play next year. You've still got it and the game needs you!

Steelers are Superbowl Champs

One for the other thumb has been accomplished. I have to confess when I first saw the schedule I thought we'd be lucky to make the playoffs. Then, we struggled with some O line problems, lost a long snapper and a punter. But they did it! Wow!! Great job guys!!!!! Just one request - could we please start putting teams away a little earlier?! I'm getting older and I'm not sure if I so many close ones in a row!!