Thursday, July 23, 2009

Vertical Centering with CSS

I've got a secret for many of you out there. You may have perused the CSS Zen Gardens of the internet in awe-stricken hope, looking for the answer to one very simple, yet extremely elusive concept... how to get your text et. al. to center vertically with cascading style sheets. First, let me say I spent a good number of hours tinkering about in the belief that I was missing just one simple point about how elements work together in HTML. No, I wasn't missing one simple point. The point, as it turns out, is that the W3C Consortium neglected to include vertical alignment capabilities for their block level elements. Don't believe me? Check out this page straight from the horse's mouth about vertically centering text and other goodies.
W3C - Centering Things

Yeah, I was a bit underwhelmed myself too. You actually have to change the display mode over to table. See, unlike other block-level elements, tables DO have vertical centering capabilities and so the workaround is to gleefully turn your DIVs, Ps, H1s, etc., etc. into TABLE wannabes. So there you have it. There is no out of the box method for vertically centering block elements in HTML via CSS without changing their display type or performing one of the other myriad CSS-kung-fu moves.

Thursday, July 9, 2009

Microsoft .NET Code Generation Error with MySQL

Sometimes in tech you're forced to combine technologies that don't always seem naturally well-matched. This is especially true when you're hosting company offers one database technology, but not another, and when the natural scripting language partner to that database is slower than than the other competing language. So that brings me to running a MySQL database with ASP.NET 2.0/3.0 running the front end. Creating a simple web-based database application is pretty trivial, but even in those cases you can run into issues with unclear solutions.
        As I was putting together a simple web application with asp.net and mysql, I ran into a mysterious and misleading error that went something like:
Failed to generate code. Exception of type 'System.Data.Design.InternalException' was thrown.

        Oddly enough, the error pointed to the first line of my DAL DataSet.xsd where the XML declaration resides. It turns out, this is not a parsing error at all, but rather an issue with the .NET compiler being unable to auto-generate the C# code from the DataSet's XML. The reason being, it couldn't find the appropriate DbProviderFactory. The solution was pretty simple in the end. All I had to do was add the following SQL DB Provider to my web.config and I was on my way.


<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net
Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory,
MySql.Data, Version=6.0.4.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D" />
</DbProviderFactories>
</system.data>