boyersnet

Our family, our website
Welcome to boyersnet Sign in | Join | Help
in Search

Chuck's Blog

Default button for ASP.NET 2.0 Forms and MasterPages

I came across an interesting scenario today that didn't occur to us in our initial development.  We use a standard master page to define our layout and within that master page we have a search box in our header with an image button.  In the content page (contentplaceholder) we have our form fields for filling out a donation profile.  It turns out when the user uses the enter key and doens't push the button, the search image button click event was being called instead of the form submit button we had intended.  To resolve this, in each content page's page_load event, we place

Me.Form.DefaultButton = Me.btnContinue.UniqueID 'set the default button for this page

to control what button click event is fired when the user chooses to use the enter key.

Pretty handy if you ask me.

Published Thursday, December 13, 2007 10:17 AM by chuck.boyer
Filed under:

Comments

No Comments
Anonymous comments are disabled

This Blog

Syndication

Powered by Community Server, by Telligent Systems
Free ASP.NET Web Hosting by ChristianASP.NET