Hurry up and register!
Wednesday, September 9, 2009
Monday, September 7, 2009
ASP.NET encourages web pages to be written as one big
<form>, and every interaction with it to be a POST to the server ("Postback" in ASP.NET). This means pages often have multiple auto-generated
<input type="submit"> elements.
On some browsers, pressing Enter causes the first submit button to be "clicked". In pages with many such buttons, that's usually not what you want. As a hack to make "Enter" do nothing on an already-built page, I added the following before any other submit button:
<div style="visibility:hidden;height:0;"> <input type="submit" value="Dummy" onclick="return false;" /> </div>
Implementation note: using '
display:none;' caused the browser to ignore it, so I had to resort to '
visibility:hidden;' and then '
height:0;' to impact the layout as little as I could. There could be cross-browser styling issues here, my specific case didn't need anything special.