HTML Table Row Height Hack

Working with a fixed height and width table I found a problem where rows were expanding too much I needed each row to only grow in height enough to contain the text and not fill the rest of the table. The number of rows was dynamic but the height fixed. The hack is simple add a height to each row of 1px which will make it so the rows only grow enough to contain your text then add a last row to act as a buffer with no height. Below the fold I have examples.

    <table height="200px">
        <tr height="1">
            <td><img src="example.gif"/></td>
            <td>Some Text</td>
        </tr>
        <tr height="1">
            <td><img src="example2.gif"/></td>
            <td>Some More Text</td>
        </tr>
        <tr><td colspan="2"/></tr> <!--The Buffer Row-->
    </table>

More →

Silverlight Image Error

While working in Silverlight I ran across a error that seemed rather odd, not because it didn’t make sense but that I couldn’t see anything I did wrong. So the error was

Unhandled Error in Silverlight 2 Application App.xap
Code: 4001
categories: ImageError
Message: AG_E_NETWORK_ERROR

While checking the Image tag in the xaml I simply couldn’t find anything wrong with it. It looked very similar to the following xaml. The user.profile_image was of course a full URI that worked fine when written directly in the browser.

<Image  Grid.Row="0" Margin="0,0,5,0" VerticalAlignment="Top"  Source="{Binding user.profile_image}" ></Image>

So that leaves me with what could the problem be, well it turned out it was simple I was a using a GIF file so http://mydomain.com/foo.gif as a source for an image simply doesn’t work as GIF isn’t supported. But really why would Silverlight not use GIF? Well simply converting the GIF to a PNG then Silverlight can handle the image just fine and display it. Although there are some issues as in Silverlight the only 8 bit and fewer PNG formats support transparency. So if the reason you were using a GIF was for transparency you will have to create an 8 bit or lower PNG. Look for a simple how to next post on converting a GIF to a PNG that Silverlight can display properly with transparency.

More →

Connector/J 5.1.6 vs Connector/J 5.1.7

While deploying a Java based auto import system I ran into a very odd problem. The code was developed and tested just fine with Connector/J 5.1.6 then while pushing to prod there seemed to be a major issue, the import would run download everything parse it and then clear out the old data but then get stuck. I would then get a series of errors java.sql.SQLException: !Statement.GeneratedKeysNotRequested! well it turned out that the prod sever had Connector/J 5.1.7 installed instead of the 5.1.6 which test had installed. This turned out to be allowing for some wrong practices when it came to prepared statements. It was a pretty easy fix yet it took a bit of time to make sure it happened every where. So why there was a change and what happened is well discussed else where and the links to those will follow. But for now here the change that needs to happen.

PreparedStatement postinsert = connection.prepareStatement(sql);

Just changes to the following. But make sure you do the change for all prepared statements that will use generated keys, its easy to miss one and have the whole app fail because of it.

PreparedStatement postinsert = connection.prepareStatement(sql,PreparedStatement.RETURN_GENERATED_KEYS);

So if you would like to read more about whats going on check out these resources:

More →

Silverlight Move Cursor to End of TextBox

While working on in Silverlight I found the need to auto populate a TextBox then shift focus to that TextBox. That was simple to do with the following code.

    txtSearch.Focus();
    txtSearch.Text = "sometext ";

But then there is a problem the cursor is at the start of the text box so if a user starts typing they end up adding to the start when I want them to just add on to the end. So after some hunting I found the SelectionStart property of the TextBox, while this may be obvious to people who work in Silverlight and C# all the time it didn’t jump right out at me so I thought it was worth talking about. So by using SelectionStart and I can move the cursor to the end and users can just append to my started search text.

    txtSearch.Focus();
    txtSearch.Text = "sometext ";
    txtSearch.SelectionStart = txtSearch.Text.Length;
More →

Go Daddy Subdomain Redirects

After seeing this great post from Jamie Thingelstad about using subdomains to redirect people to your LinkedIn or Twitter profile I thought it would be great to add that to my site.

But it was a big process that it shouldn’t have been. I found it very hard to actually find where in the my Go Daddy hosting where to put the subdomain. So if you are doing hosting with Go Daddy and have used their subdomains tied to a folder you have to goto a completely different section to do this type of redirect. It’s in the domain management which one would expect but I look right past the correct section at least a half dozen times, so below there is a picture below the fold with a red box showing exactly where to add the subdomains.

The process is simple once you find the correct section. Simply click add then fill out the “subdomain” and “forward to” fields as an example I did “subdomain”: twitter and “forward to”: http://twitter.com/beckje01 Those simple steps have now set up http://twitter.jeffbeck.info to link to my twitter account.

subdomain

More →