Thursday, August 17, 2006

Making DIVs stay next to each other

A colleague came to me with a very simple issue yesterday.  He had a table surrounding the area he was working on, and he wanted to have 2 DIVs side-by-side, one of them containing a table.

Here’s what he had:

<table>
 <tr>
  <td>
  
   <div style="padding: 2px; margin: 2px; border: #ccc; background-color:#eee;">
    here's the first div
   </div>

   <div style="padding: 2px; margin: 2px; border: #ccc; background-color:#eee;">
    ..and here's the 2nd
    <table border=1>
     <tr>
      <td>with a table</td>
     </td>
    </table>
   </div>
  </td>
 </tr>
</table>

...which looks like:

here's the first div
..and here's the 2nd
with a table

 

He tried a number of things that didn’t work.  Here’s the solution:

DIVs are block level elements that stretch to 100% of the width of the parent container.  So to get them to sit next to each other you first need to give them some room to do so.  Set the width so that they will both fit (be sure to account for border + margin as well).

The next thing to do is set the DIVs to float:left;  This will make them push up next to each other until there is no more room, then they will wrap.

Here it is in action:

 <table>
 <tr>
  <td width="300">
   
   <div style="margin:2px; padding:2px; border: solid 1px #bbb; background-color: #eee; float: left; width: 75px;">
    here's the 1st div
   </div>

   <div style="margin:2px; padding:2px; border: solid 1px #bbb; background-color: #eee; float: left; width: 75px;">
    ..and here's the 2nd
    <table border=1>
     <tr><td>with a table</td></tr>
    </table>
   </div>
  </td>
 </tr>
</table>

here's the 1st div
..and here's the 2nd
with a table

 

Understanding how floating works is an important part of effective CSS web design.  I may consider some more of these simple examples if they are of help to my readers.

Newshutch is my friend

For my RSS Feeds I had previously used RssReader.  I used it because I wanted a windows application that would notify me of new posts and not be too obtrusive.  RssReader is pretty nice, but the interface needs quite a bit of polishing.  I also disliked not having a distributed opml or something so that I could access all of my feeds on another computer.

I have since crossed over and succumbd to web-based RSS Feed readers.  I’ve tried Google Reader, Newsgator, Bloglines, and others… but I didn’t like any of them.

My new friend for RSS feeds is Newshutch.  Incredbily simplistic, but functional.  The interface doesn’t get in my way and the nice use of Ajax means that I can leave the window open and it will automatically get my feeds for me.  As I read an entry, I can click 1 button and have that entry fade away and the ones below it to float to the top.  This fits nicely with the way I like to read blog posts, so this one is most-likely here to stay.

Sunday, July 23, 2006

A Journey with Domain Driven Design (and NHibernate) - Part 4

In Part 4 of the series, I dig deeper into the tests to fill out the requirements. We talk briefly about some Domain Driven Design concepts and finish up with enough functionality to move on to the database.
Wednesday, July 19, 2006

A Journey With NHibernate (and DDD) - Part 3

In Part 3 of the series, I jump head first into unit testing our domain model with NHibernate.
Monday, July 10, 2006

A Journey With NHibernate - Part 2

In Part 2 of the series we create our project structure and introduce a first-draft implementation of our model.
Wednesday, July 05, 2006

A Journey with NHibernate - Part 1

In this series of articles we will dive into the world of Domain Driven Design. Along the way we'll focus on concepts of Object Oriented Design, Test Driven Development, Refactoring, and Object-Relational Mapping with NHibernate.
Thursday, June 29, 2006

AnkhSVN Supports Visual Studio 2005

I just learned that AnkhSVN now supports Visual Studio 2005.  Sweetness.

Ankh is by no means a replacement for TortoiseSVN, but rather a plugin for VS that makes your life a bit easer.  Tortoise and Ankh go hand in hand with each other. 

Usually I commit my changes, add my files, and call Update directly from Ankh.  Sometimes, for example with files outside of VS, I’ll use tortoise.

In the event that something is screwed up, Tortoise is the way to go to get things on the right track again.  You just have so much more capability with that tool.

Wednesday, June 28, 2006

TransactionScope + MSDTC + Windows 2000

For my data access unit tests, I am a huge fan of the new System.Transactions namespace in .NET 2.0.  Basically I can define my unit tests like this:

using System;

using NUnit.Framework;

using System.Transactions;

 

[TestFixture]

public class TestClass1

{

    private TransactionScope _tx;

 

    [Setup]

    public void SetUp()

    {

        _tx = new TransactionScope();

    }

 

    [TearDown]

    public void TearDown()

    {

        _tx.Dispose();

    }

 

    [Test]

    public void TestSaveSomeData()

    {

        //some code that inserts data into the database

    }

}

Without the TransactionScope above, we would end up with a bunch of junk data in the database.

What’s great about this method, is that – from the bottom layer – I can start a transaction, do all kinds of inserts/updates/deletes and even select from that data, and then roll the entire thing back when I’m done.  (Even in the event of failure).

What’s not so nice is that TransactionScope uses MSDTC (Microsoft Distributed Transaction Coordinator) behind the scenes.  This is fine locally as long as you have the service running on your machine.  But what if you try to do this on a database on another server?

In my case I was connecting to a Windows 2000 Server on the local network.  The MSDTC handshake was failing.  This was due to security settings built into Windows XP SP2.

I received enourmous help from Florin Lazar’s blog post: http://blogs.msdn.com/florinlazar/archive/2004/06/18/159127.aspx

I opened up Administrative Tools -> Component Services , right-clicked on My Computer and selected Properties.  Under the MSDTC tab, I clicked Security.  Then I enabled Inbound and Outbound connections, and set the authentication to “No Authentication Required”.  That last part is kind of confusing, but basically it’s required for pre-XP/2003 machines, such as NT or Windows 2000.

Now my transactions are running again.

Visual 2005 ReportViewer Doesn't Work With MSSQL 2000

I was trying to connect a 2005 WinForms ReportViewer control to a SSRS 2000 report server and I kept getting an HTTP 404, even though the url was correct.

Apparently it’s not supported.

The error message did say “Make sure this report server is compatible with the ReportViewer” but I think that’s something that they should just come out and tell me.  I mean, come on… ReportViewer 2005 can easily recognize that I’m connecting to a 2000 report server.

I had to spend 20 minutes searching the internet to get a definitive answer.  Hopefully this will save someone some grief.

 

Tuesday, June 27, 2006

Is Songbird the media solution Im looking for?

I just discovered this today:

http://www.songbirdnest.com/

It’s called Songbird and I think they’re on to something.  Just admit it:  Our current media situation sucks.  I posted about this previously and ranted about how much I hate most media players.  Anyway, I settled for iTunes, but not because I love it, only because it’s the lesser of other evils (IMHO).

Songbird is taking a different approach to media players, integrating it more closely with the web, and it’s built on top of Firefox, so it’s cross-platform and have rich plugin support.  I’m really looking forward to some of the extensions that will become of this.

It’s based on XUL, which should impress some super-techies out there .   I wonder how nicely this will work with a distributed scenario like iTunes + FolderShare?

Debt - Credit Card Consolidation - Credit Counseling - Arizona Pools