Tuesday, April 1, 2008

Whither form posts, Safari?

Now, in the "code" department...

I'm writing this for the benefit of the web-at-large, as nobody else appears to have commented on this behavior in my Googling.

Say you have an ASP.NET form with a FileUpload (<input type="file">) element in it. You leave the element blank and submit the form.

Internet Explorer and Firefox both send all of the form elements to the server, with no file.

Safari, on the other hand, sends an empty form post.

That makes ASP.NET sad, as none of the hidden ViewState fields are sent. Which means that your Button_OnClick bindings won't work, because they rely on the ViewState to know what just happened.

Here's my solution: for Safari, remove any blank file elements before the form is submitted.

The problem exists on both Safari 2.0.3 for OS X and Safari 3.1 for Windows.

This solution should work, but is not tested as written (I changed it to an anonymous function for this blog post). It requires Prototype.js.

@"(function() {
if (Prototype.Browser.WebKit) {
var pageForm = document.getElementsByTagName('form')[0];
var inps = Form.Methods.getInputs(pageForm, 'file');
inps.each(function(inp) {
if (inp.value == '') Element.remove(inp);
return true;

Sunday, March 16, 2008

Pain à l'Ancienne

All kinds of news from out here.

We just had an offer accepted on a house! So if you thought I didn't post very often before, now it's going to be even less for a while!

Second, I may have some sort of allergy. Possibly to wheat. So who knows how long this blog will last.

But third, my wife bought me a copy of The Bread Baker's Apprentice for my birthday. And in it is a recipe for Pain à l'Ancienne.

And it is goooood.

I feel that it would be doing the author a disservice to post the recipe for this one. Besides, you really have to get into the first few chapters to understand the theory behind it. But basically, it's completely different from every other bread I've made.

For one, there's no kneading. For another, you use ice cold water -- as in refrigerated for several hours, then with ice added to it. You use less than a teaspoon of instant (quick-rise) yeast. You mix the basic ingredients together (flour, water, yeast salt), then stick it into the fridge immediately to keep the yeast from being too active. The dough is so wet you couldn't possibly do any kneading. And the oven is preheated to 500 degrees, then turned down to 475 only after you've given the bread three steam baths, one every 30 seconds.

But it's eye-opening. The flavor and texture are fantastic -- a cut above anything I've ever baked. We went through almost an entire baguette last night at midnight, after it had cooled enough to eat. I think I'm going to break into another one in a minute.


Thursday, February 28, 2008

A new era awaits

So I've finally reached a point of frustration with my bread. I can make tasty flavors, but textures? They're all kinda... sandwichy. You know -- even crumbles throughout, with now real elasticity and certainly none of the great air bubbles you get in artisan breads. So I decided to Ask Metafilter what I could do to improve things, and received some excellent responses.

The missus used that info to get me a terrific present for my birthday: The Bread Baker's Apprentice. I'm hoping this takes my bread baking skills to the next level. Will update you on my progress sometime in my next post, which at my current posting rate will probably be in mid-2010.

Friday, January 25, 2008

Redfin Walkability, Challah

Sorry for the delay and lack of bread. I've actually become the master of Challah over the past few weeks. Here's a generic Challah template:
1 c water
1 egg
1/4 c honey
1/4 c canola oil
1 scant tbsp yeast
2 tsp salt

1 more egg, beaten with a tbsp of water
Sesame seeds

Mix all the above together. Add in flour slowly until the dough is kneadable. Knead for 5-10 minutes. Let it sit for an hour until doubled in bulk. Punch down and braid. Let it rise another 45 minutes. Brush with the egg/water mixture, then sprinkle sesame seeds on top.
Pop it into a 350 degree oven for 20 minutes. After 20, be vigilant -- the sugar and egg conspire to make this burn quickly and without warning!

We're in the market for a home, and using RedFin to find properties. Our knowledge of neighborhoods is still not great, but we know wherever we end up we want to be able to walk to the grocery store, a coffee shop, and other things. Here's a little GreaseMonkey script that adds a "Get WalkScore" link below a property's address on RedFin. It just links over to WalkScore.com with the current property. Handy!
Website Counter