November 2009 Posts

27Nov/09Off

ASP.NET DefaultButton Property and FireFox

Whilst developing a website at work this week I encountered two issues with the use of default buttons in ASP.NET. Both issues were encountered when using FireFox, but potentially this may apply to all non-IE browsers. Note that this relates to ASP.NET 2.0, so things may be different or even hopefully fixed in later versions of the framework.

Issue 1: Using a LinkButton as the default button of a Panel control does not work in FireFox

The build of the website I have been developing uses styled hyper-links in place of submit buttons, so naturally I implemented these using LinkButton controls allowing for simple postbacks and server-side event handling. Wanting to avoid random submits when a user hits the return key in a form, I wrapped each form in a Panel control and set the DefaultButton properties to the relevant submit LinkButton controls. This works fine when viewing the site in Internet Explorer but does not work in FireFox.

Issue 2: Defining a default button for a Panel control breaks the return key in multi-line TextBox controls in FireFox

Several of the forms on the site require multi-line TextBox controls for such things as description fields. Once again this works fine in Internet Explorer, but has soon as the TextBox is within a Panel with a default button set it breaks in FireFox. Instead of breaking to a new line, the default button is clicked.

12Nov/09Off

404 Errors When Integrating Zenphoto With WordPress

The Problem

In my previous post, 'A Basic WordPress And Zenphoto Integration', I noted that my Zenphoto integration had a problem with silent 404 errors. Although the pages of the gallery were being displayed nicely skinned with my WordPress theme and everything looked okay, behind the scenes they were being delivered to the browser with a HTTP status of 404, "not found". Obviously this is a very bad thing, as once I manage to get search engines indexing my site they would see the 404 and assume that the pages were not available, ignoring the fact that the content was actually there.

The Details

Some comments on the original post that I used to aid my integration suggested that this was being caused by the URL rewriting used by both WordPress and Zenphoto. Taking this lead, I did a few simple tests to narrow the location of the problem. First I disable the URL rewriting in Zenphoto. No change. Second, I disabled the URL rewriting in WordPress. Bingo; the gallery pages were now being served with a HTTP status of 200, but now my WordPress URLs were decidedly less than friendly.

Time for a bit of digging into how WordPress handles URL rewriting. Actually, not much digging was needed in this case. As the gallery is located in a sub-folder under the WordPress installation, I figured all that was needed was to make WordPress ignore this entire sub-folder when it comes to parsing rewritten URLs. This led me to 'WP_Rewrite' in the WordPress Codex. This class, defined in wp-includes/rewrite.php, handles all of the URL rewriting rules used by WordPress.

5Nov/09Off

A Basic WordPress And Zenphoto Integration

Having installed both WordPress and Zenphoto, it is now time to see how to integrate the two. A bit of searching through the WordPress Plugin Directory and quick session on Google led me to the work of three people that would help me to accomplish a pretty damn good integration.

ZenphotoPress

The first step was to install the ZenphotoPress plugin by Alessandro Morandi found in the WordPress Plugin Directory. This awesome plugin provides shortcode support and a dialog in the WordPress editor for inserting images from Zenphoto directly into posts and pages. For example, here are a few shots I took at a big cats workshop back in March 2009:

Ocelot Leopard Leopard Ocelot Snow Leopard Mountain Lion

The plugin gives a variety of options when inserting, such as whether to insert the image, it's textual name or custom link text. You can choose whether to link to the album, the individual picture page, a custom URL or even no link at all. Other options include such things as text wrapping and image size. In the example above, I have opted for thumbnail sized images linking to the main gallery page.