Friday, December 05, 2008

Multiple Default Buttons on a single asp.net Form

When in need of multiple default buttons on a single form. I set the onKeypress event to handle the postback if user hit on the "Enter" key. This works great to set a default button for any input control.

txtDuplicateDescription.Attributes.Add("onKeyPress", "javascript:if (event.keyCode ==
13) __doPostBack('" + imbSaveAndView.UniqueID + "','')");