DefaultButton Attribute in ASP.Net

I just found a cool attribute that you can use on many of the ASP.Net 2.0 and above controls.  Its the DefaultButton attribute.  You can use this on the Form tag to make one default button for the entire page or you can use it in the ASP Panel to make one default button for just that area of the page. 

It’s quit simple to use.  I had two different areas where users can enter values in a text box.  I found myself typing in values and hitting Enter to submit.  Well, the Enter key would cause a refresh of the page, but my handlers were not firing.  I added a panel around these two areas, set the DefaultButton attribute and bam, it works great now!

Posted in |

0 comments: