Archive for February, 2009

Ajax TabContainer Validation Solution

February 25, 2009

If you have ever tried to validate controls on a ajax TabContainer when you change tabs you will have run into a couple of issues.

The first of those is that you cant set the validation group etc for the TabContainer or panels. You don’t want to do serverside validation so you think of using the OnClientActiveTabChanged event somehow to fire the validation events.
You soon find out that using the OnClientActiveTabChanged event is not that simple. You need a javascript function for it, inline is not allowed. If you have UpdatePanels and/or you are on a user control you will have some fun getting the javascript function to be registered.

You naturally leave your server side OnActiveTabChanged event as is thinking that if you get the validation events to fire that the server side call will be stopped. Think again, because the TabContainer uses AutoPostback = “true” the server side event is fired anyway and validator error text disappears after the postback is complete. If you remove AutoPostback then you cant get the server side OnActiveTabChanged event to fire…and there is more fun to be had there.

Here is a simple alternative. Remove the AutoPostback and dont use the OnActiveTabChanged event. In your HeaderTemplate place a LinkButton and add the validation group you want to use to that. Then link the OnClick of the LinkButton to fire serverside when you need it. The validation fires correctly but you still have to stop the tabs from changing on validation error manually. To Do that you hook into the OnClientActiveTabChanged event and just check if validation was successful or not before moving to the selected tab.

Here is the client script, if you need the rest of the code let me know. I am still battleing to get html code into this blog.

    var currentTabIndex = 0;

                var nextTabIndex = sender.get_activeTabIndex();

                if (Page_ClientValidate("My Validation Group")) {
                    // Save the current tab index so we can reference it next time.
                    currentTabIndex = nextTabIndex;
                else {
                    // Setting the activeTab below will trigger this function again
                    // So, to make sure we don't get caught in a loop, make sure these values aren't the same                
                    if (nextTabIndex != currentTabIndex) sender.set_activeTab(sender.get_tabs()[currentTabIndex]);

The script was hacked form

Ps: Thanx to Jaco for coming up with the linkbutton idea.

WordPress Format Code Quicky

February 24, 2009

After wasting hours trying to get something to format my code examples for my free WordPress blog I found that the pre tag does most of what is needed…indention. If you don’t need fancy syntax highlighting out of the box this is the solution involving the least effort.

Wrapping the <pre> tag in <div style=”overflow:auto;”> will take care of the code going over the borders of the post.

Hunchentoot & Postmodern Quicky

February 23, 2009

I have only been using hunchentoot and lisp seriously for a few months. I AM NO expert in lisp or hunchentoot so please feel free to correct and/or chastize me regarding anything in this little piece.

Firstly get everything you need installed! (Script to follow one day…)

The example website uses hunchentoot 1.0 and postmodern, I tried to include a variety of features that you would find on a average website, stuff like style sheets, javascript, images, some db integration and of course a kewl “made with lisp” logo from

The example has 2 pages for now, a login and home page with all the user and roles plumbing needed. The roles and user stuff comes form a postgresql database and we use postmodern to get to it. In a follow up piece I will add a biographical screen, displaying the data in a grid with all its parafinalia (editing, paging, search etc).

This piece is not for absolute newbie’s but for some one that has the basics of lisp and just wants to see hunchentoot and postmodern in action together.

For now I am only adding the code needed. I will keep on hacking away at it till it looks more like a tutorial.