One of the things that often crops up when designing asp.net web pages, and testing them in ie, is that there does not seem to be an easy way to set the default button. This is the button that would be "clicked" when the user just presses enter on the form, and it's a feature of ie.
Previously I have solved this through client-side javascript, but I recently came across a much neater solution in Mike Webs blog. He has a good explanation of how it works so I won't go into it here, save to say that all you need to do is add the following to your page_load event:
Page.RegisterHiddenField("__EVENTTARGET", "MyDefaultButton");
This seems to work a treat, and Mikes's explanation certainly makes sense. This is a whole lot easier than using Javascript or custom controls too..
posted @ Tuesday, March 09, 2004 7:41 AM