4 Jan 2006

ASP.NET 2.0 default form buttons

Back in the old days we used to be able to put as many forms as we liked on a page. One cool thing about that was they could be set to action on different pages, and the appropriate submit buttons would fire when Enter was pressed.

Now ASP.NET only really allows us to use one form (without nasty hacks) on a page, we have the problem that any submit button is potentially the target of the Enter key.

I did an ASP.NET 1.1 site where I had to solve this prob and used the MetaBuilders solution: http://www.metabuilders.com/Tools/DefaultButtons.aspx

Well, I just found out that the Panel object in ASP.NET 2.0 has a DefaultButton property which applies to all the child inputs of the Panel. Lordy loo.

There is a drawback however - it requires Javascript to work (like so many other ASP.NET controls). I'm no JavaScript hater but bear in mind that WCAG 1.0 Level A requires a site to work without Client Script. Nothing's ever easy is it?

No comments:

Post a Comment

Comments are very welcome but are moderated to prevent spam.

If I helped you out today, you can buy me a beer below. Cheers!