About your host

Photo of your host - Charles Vallance Charles Vallance is a web developer with a slight case of OCD when it comes to nice clean standards compliant html and code.

Badges

twitter / cvallance
My articles have been featured in The Morning Brew - Daily .NET News and Views

Tag Cloud

more tags...
August 2007 Entries

I've recently become the proud owner of an old server that my mother doesn't require anymore. It's nothing too fancy at all, just a Xeon 2.4 with 512mb. But its good fun none the less! :-)

Currently I've got it set up with Win2K3 with SQL Server 2000 Developer Edition for my developments and testing. Also, I've moved my SVN server onto it, and my previous post about setting up SVN server on XP came in really handy.

This is all good because it's taking a bit of the load off my XP box which is getting a little bit long in the tooth itself! But it's actually creating a few headaches too...

For some reason, I thought it would be a good idea to create the SQL 2000 server as a named instance (with no default instance either)... which is, apparently, not such a good idea.

You see, I can't create a remote connection to it... which has numerous repercussions. The main pain in the behind, is that I can't run a web app on my local iis and talk to the database. Which in turn means I can't use VS's debugging for any of my aps that use the sql server. I've only got VS 2005 standard editionat home which means no remote debugging. :-(

This is the error that is currently fueling my frustation:

provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified

This is a real massive pain when I'm trying to learn Castle (the trunk version) in all its wonderful glory. *sigh*

Hopefully a SQL server reinstall should do the trick... or am I missing something here? I mean, I've tried every single help article on the net and nothing seems to work. This post looked promising at first but ended up being another hit and miss.

It's probably just a limitation of SQL Server Developer Edition... Hmmmm, back to google I guess.

[EDIT] SP4 fixed my problem!

Technorati Tags: ,

I've been doing a bit of experimentation with Castle Validation recently and thought I should write about a few of my findings... also found a couple of oddities here and there which Hammett squashed very quickly.

Setting up the validation rules was as easy as 1, 2, 3. It was just a matter of adding some validation attributes to my public properties in my ActiveRecord classes. Eg.

[Property]
[ValidateNonEmpty("First name is required")]
public string FirstName {
    get { return _firstname; }
    set { _firstname = value; }
}

I could quite easily dictate how the validation errors were rendered to the user after server side validation but the client side validation was another story.

When a rule fails, it basically throws a div after the form element. A little bit like this:

<label for="user_FirstName">    
    <span>First name<sup>*</sup></span>
    <input id="user_firstname" name="user.firstname" value="" class="required validation-failed" title="First name is required." type="text">
    <div class="validation-advice" id="advice-required-user_firstname" style="opacity: 0.999999;">First name is required.</div>
</label>

The first thing you'll notice (actually, probably not actually without seeing my css) is that this is going to severly stuff up my look and flow. Things get even more higgle-te-piggle-te when you have the immediate set to true on the formtag.

[NOTE] My print screen button doesn't seem to be working right now, weird, but I'll get some screen shots up as soon as I can.

At this stage you're probably all thinking - big deal, suck it up buddy and use your css fu to style div.validation-advice! And that's a fair call... if you stop reading here.

Say you have this:

[Property]
[ValidateNonEmpty("Email is required", ExecutionOrder=1)]
[ValidateEmail("Email isn't a valid format", ExecutionOrder=2)]
[ValidateIsUnique("Email already exists, visit forgot password page to reset your password.", ExecutionOrder=3)]
public string Email {
    get { return _email; }
    set { _email = value; }
}

Now when you ommit an email address, you get this in the rendered div:

<div class="validation-advice" id="advice-required-user_email" style="opacity: 0.999999;">Email is required. Email isn't a valid format.</div>

Now if you enter something in the email field but its not a valid email address you get this:

<div class="validation-advice" id="advice-validate-email-user_email" style="opacity: 0.999999;">Email is required. Email isn't a valid format.</div>

[NOTE] ValidateIsUnique doesn't display because this is done server side.

Now this isn't ideal to say the least. It is because the castle client side validation uses the title of the input for the error message... and this obviously can only contain one string.

But not to worry my friends, I found a way around it! :-) Albiet, in my opinion, an ugly one.

Using this post here, I experimented with inserting my own .validation-adivce elements with the id's given to me when castle rendered its own client side validation. So after a bit of experimentation, I found it all working fine and dandy.

So this code here, which contains several rules and looks extremely bloated, makes the castle client side validation work more to my liking:

<ul class="validation-errors">
    <li id="advice-required-user_firstname" class="validation-advice" style="display: none;">First name is required</li>
    <li id="advice-required-user_lastname" class="validation-advice" style="display: none;">Last name is required</li>
    <li id="advice-required-user_email" class="validation-advice" style="display: none;">Email address is required</li>
    <li id="advice-validate-email-user_email" class="validation-advice" style="display: none;">Email address is not valid</li>
    <li id="advice-required-user_dateofbirth" class="validation-advice" style="display: none;">Date of birth is required</li>
    <li id="advice-validate-date-user_dateofbirth" class="validation-advice" style="display: none;">Date of birth is not valid</li>
    <li id="advice-required-user_password" class="validation-advice" style="display: none;">Password is required</li>
    <li id="advice-validate-min-length-3-user_password" class="validation-advice" style="display: none;">Password must be between 3 & 12 characters</li>
    <li id="advice-validate-max-length-12-user_password" class="validation-advice" style="display: none;">Password must be between 3 & 12 characters</li>
    <li id="advice-required-user_confirmation" class="validation-advice" style="display: none;">Password confirmation is required</li>
    <li id="advice-validate-same-as-password-user_confirmation" class="validation-advice" style="display: none;">Passwords don't match</li>
</ul>

I wonder if I could write some sort of component that could spit out that code for me... maybe I shall look into that when I return from skiing. Yowl!

Technorati Tags:

Wow, it's been a while since my last post! I've been a busy man in between work and roadies up the mountain. I knew I would find it hard to find time for this fandangled blogging thing. :-)

Anywho, thought I might just knock one or two off before I head off on holiday. Where am I going you ask...? I'm off to Wanaka for 6 days skiing! Yowl! Can't wait... I even heard that shapeshifter is going to be playing down there... might have to get my dancing shoes on and bust out a two foot stomp! ;-)

The straight after my time in Wanaka I'm flying up to Auckland for Microsoft Tech Ed... it'll actually be the first one I've ever been to. Excited? Yes.

I was doing some random surfing the other day and stumbled upon this post from Rod Drury. He makes the Saffron Restaurant sound absolutely magical, hopefully I'll get a chance to check it out when I'm down there.

But what really struck me about the post was the little note right at the end about Web on the Piste. How on earth did that slip under my radar?!?! Rather gutted I didn't know about it, I would've been there in a flash! It's like my two passions mixed into one!!! Oh well, there's always next year... here's hoping anyway!

Technorati Tags: