Simple CSS Trick

At best I’m a CSS hacker, but every now and then, I actually learn something cool about CSS.  Today, I finally figured out how to make a dynamically expanding div container.

Basically I have a ‘mainContent’ div container where the height is unknown based on the content (additionally, I have a floating div).  In order to dynamically grow the content div I use this style:

#mainContent {
	border: 1px solid #000000;
	overflow: hidden;
	width: 100%;

div.left {
	width: 45%;
	float: left;

div.right {
	width: 45%;
	float: right;


The key here is the ‘overflow: hidden’  on the “container” div (id is mainContent).  This works well both in Firefox and IE (7, not sure about 6)

Probably everyone knows this already, but figured I’d share  🙂

ASP.NET MVC Preview 3 Release

I’ll write up more as I explore…

Update: so far… excellent work.  The different return results from Actions are very powerful  – JsonResult, ActionResult, ContentResult

Take the JsonResult.  Previously I created a ‘ToJson’ extension method with a response.write on a void action call.

With preview 3, I return a JsonResult instead, and use the ‘Json’ function that does the same thing my extension method was doing and then returns the JsonResult.  For example:

        public JsonResult SetClaimReadyToPrint(string id) //claimid
            try {
                Claim claim = ClaimsDao.GetById(new Guid(id), true);
                if (claim.ClaimStatus == ClaimStatus.P)
                    return Json(new JsonData(true, "Claim has already been paid");
                claim.ClaimStatus = ClaimStatus.R;

                return Json(new JsonData("Set to Ready to Print"));
            catch (Exception ex) {
                return Json(new JsonData(true, "Error setting to ready status " + ex.Message));

I am using my ‘JsonData’ class- a serializable object to store the results

With just content, I use the ContentResult – this replaces any ugly ‘response.write’ calls.

The best part of all (outside of readability and no response write!) is that it’s easy to test!

Ruby on Rails

After my IronRuby posts, I thought I would go back to Ruby on Rails, get it setup again and pick up where I left all from a few years ago.

My first step this time was to grab ‘RadRails’ from Aptana.  I setup a RoR project and right away realized I didn’t have the standard ‘mysql’ database, etc…

At first I started to go get it, but then thought : why go through that, when I have a database installed (MS SQL 2005).  Quick google search on RoR with Sql took me here:

Quick, clean, and to the point – excellent.

Ran the sqlserver adapter gem, setup the security, copied the ADO.rb file as it says, updated the database.yml and I was ready.

Aptana has a nice ‘homepage’ they give you as part of the setup of a new RoR project, which took me through about 3-4 steps to create a scaffolding.  I like Aptana’s tasks at the bottom of the editor: Generators/Rake Tasks, etc… so it was rather easy to setup.

Luckily for me it all ran well, and I ran the app. Presto, works great.

It’s VERY interesting coming back to RoR after looking at Monorail and then the use of the MS MVC.  All I can say is that I have a much different perspective of rails now  🙂

I’m big into jQuery – and I understand Rails is more ‘prototype’ oriented ?  Not a big deal, but I’d like to stick to my jQuery.  So I’ll have to investigate this.

Also, this time around, after working with NHibernate, etc.. I’m curious how RoR ActiveRecord matches up.


As a complete newbie, I’ll share some experiences as I learn:

1. a good intro – watch the 5 minute movie:

2. some important getting started with IronRuby on the wiki:


3. Defining MVC Routes and Views in IronRuby:

Now if I could just figure out how to set the environment variables to run rake (yes, I’m a serious newbie here!) I must have had a faulty install, I reinstalled ruby and it works fine

My new dream is to run a MS MVC application written in IronRuby.  Perfect.  🙂  (I think this is better than IronRuby on rails approach)

Vista Home Premium to Vista Ultimate – 10 hours and 20 minutes…

Due to getting the M$Shaft, I had to upgrade to Ultimate.  It cost another $180 to do it.  The entire reason was because M$Shaft decided that Home Premium wouldn’t have the authentication required in it’s IIS – so I can’t run Reporting Services.  Then, the Virtual PC doesn’t support Home Premium either.

But ok, so I get the upgrade.  It took 2 hours to examine my machine to check compatibilities.  It took another 8 hours (I started it at 6am this morning, finished at 2pm) to perform the upgrade.  Then another 20 minutes to ‘check my computer performance’.  I run a Core 2 Duo with 2 gigs of Ram.

On the package it said 32-bit or 64-bit.  I was happy, thinking I would upgrade to 64-bit.  But no, nowhere did it say that you can only go from 32-bit to 32-bit.  So another major disapointment.  I suspose when I buy 2 more gigs of memory to run this hog, I will have to reformat and take another 10 hours to install the OS.

Lets be frank – I only run windows software on this work laptop in order to run my development environment.  That is shame, as I would be more than willing to run Linux, etc… if it could run all my software.

I guess once MS hooks you into using some of their software, they proceed to rake you over the coals in expenses.  $180 and 10 hours to upgrade… amazing.



Ok, this is a first and hopefully a last.  I tend to stay strictly technical here on this blog.

But, I have to comment on this one  🙂

Rant start:

Basically, I think the US suffers from an energy management problem.  We are very dependent on oil. 

GDub summed it up here:

“It’s not enough. It’s something but it doesn’t solve our problem,” Bush said. “One of the interesting things about American politics is, those who are screaming the loudest for increased production from Saudi Arabia are the very same people who are the fighting the fiercest against domestic exploration, against the development of nuclear power and against expanding refining capacity.”  (site reference )

Reducing dependency on foreign oil MUST be a priority.  The impact of gasoline prices effects EVERYTHING in our economy.  It raises the price of shipping, production, etc… – which in turn causes the added price to be applied to everything we buy as a consumer.

This election season, I urge everyone, regardless of your political party views to make sure your candidate and congress representative is working to allow the US to be dependent on it’s own resources vs. foreign dependencies.  We have the resources, but politics blocks those capabilities. 

Rant over.

Back to coding…  🙂

Sharp Architecture

Billy has posted his new best practices with mvc, nhibernate and  This is the same architecture that I have been using (we have conversed on a few emails) and it’s a good setup. 

Those 3 frameworks together can provide a good sound solution. handles the dependency injection of controllers and dao/repository objects as well as manage the nhibernate session and transactional support.

As he mentions in the documentation, Ayende’s NHibernate Query Generator is a ‘must have’ for me with nhibernate. It integrates into Visual Studio and gives a ‘linq like’ expression language for your dao/repositories.

Great stuff as always from Billy.  Here is a direct link to the codeplex setup:

(Side note:  It would be good to see Spring.NET provide Entity Framework support for handling the DataContext.)

I’d like to add into this architecture the use of jQuery for all the client side/ajax/UI control needs.  Obviously there are several good javascript packages available (Prototype, Dojo, YUI). I have found jQuery to handle just about everything I have needed in my projects.  jQuery allows for the use of unobtrusive javascript development.

examples of how I’m using jQuery:

  • good ajax support – including jQuery forms – allowing forms to be posted via ajax with validation
  • validation support
  • table sorting/paging support
  • autocompletion
  • tab controls
  • date controls
  • input masks
  • modal popups
  • etc…

the jquery website has links to hundreds of user created solutions.  (I use Firebug as well for debugging my javascript and ajax code)

ASP.NET MVC and Repeater

Article here:

My response – we have a repeater already, works fine with MVC and is easy to style and add paging, sorting, etc… thanks to my good friend jQuery…


At the top to setup jQuery:

                container: $("#pager"),
                size : 5,


at the bottom to setup the pager:


<div id="pager" class="pager">
<img src="/FooWeb/Content/Images/jQueryGrid/first.png" class="first"/>
        <img src="/FooWeb/Content/Images/jQueryGrid/prev.png" class="prev"/>
        <input type="text" class="pagedisplay"/>
        <img src="/FooWeb/Content/Images/jQueryGrid/next.png" class="next"/>
        <img src="/FooWeb/Content/Images/jQueryGrid/last.png" class="last"/>
        <select class="pagesize">
            <option selected="selected"  value="5">5</option>
            <option value="10">10</option>


Now the guts of the matter:


<table id="barTable" class="tablesorter">
        <asp:Repeater ID="BarRepeater" runat="server" OnItemDataBound="ShowBarItems">
                        <%#Eval("ServiceProvidedDate", "{0:d}")%>
                        <%#Eval("DateInput", "{0:d}")%>
                        <%#Eval("Amount", "{0:C}")%>
                        <%#Eval("AmountPaid", "{0:C}")%>

Need databinding events?

<asp:Repeater ID="BarRepeater" runat="server" OnItemDataBound="ShowBarItems">

Nothing new needed.

Hook it up in the View code behind:

public partial class BarView: System.Web.Mvc.ViewUserControl<IList<Core.Domain.Bar>>
        protected void Page_Load(object sender, EventArgs e)
            if (ViewData.Count > 0)
                BarRepeater.DataSource = ViewData;

        protected void ShowBarItems(Object sender, RepeaterItemEventArgs e)
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                var bar= e.Item.DataItem as Bar;
                if (bar!= null)
                    ((Repeater)e.Item.FindControl("BarItemRepeater")).DataSource = bar.BarItems;

                    if (bar.BarStatus == Core.EnumClasses.BarStatus.S)
                        var EditLink = e.Item.FindControl("EditLink") as HyperLink;
                        if (EditLink != null)
                            EditLink.NavigateUrl = string.Format("/FooWeb/Bar.mvc/EditExistingBar/{0}",bar.BarID);

                        var CompleteLink = e.Item.FindControl("CompleteLink") as HyperLink;
                        if (CompleteLink != null)
                            CompleteLink.NavigateUrl = string.Format("/FooWeb/Bar.mvc/CompleteBar/{0}", bar.BarID);

                        var CompleteAndPrintLink = e.Item.FindControl("CompleteAndPrintLink") as HyperLink;
                        if (CompleteAndPrintLink != null)
                            CompleteAndPrintLink.NavigateUrl = string.Format("/FooWeb/Bar.mvc/CompleteAndPrintBar/{0}", bar.BarID);


Learn more about the jQuery tablesorter here: