Multiple Forms and the Enter Button in ASP.NET 2.0#

If you are using ASP.NET 2.0 and have multiple forms or submit buttons, you may have found out that you can only have one form tag in the master page and are not allowed to have another form tag in the page. 

If you want to have the user press the enter button on the keyboard to cause any of your multiple submit buttons to submit, you have to use the <asp:Panel control and set the DefaultButton property equal to the button id that is in that panel. 

For example, I had an asp:Login control in a master page and also a search form.  When the user wanted to search and hit the enter key, it would try to login.  You could set the DefaultButton property in the master form element, but that is also dangerous if you have other forms throughout your site.  Also if you want to have it work depending on where the user has focus, then you have to use the panel control.

Tuesday, November 07, 2006 8:48:58 AM UTC #    Comments [1]  |  Trackback

 

Saturday, November 15, 2008 4:40:52 PM UTC
suchitra
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, i, strong, u)  

Enter the code shown (prevents robots):

 

All content © 2009, Jim Zimmerman
Book
New Book
Links to me
On this page
Sponsors
Calendar
<November 2006>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
Archives
Tags
Blogroll OPML
Technorati
Favorite Links
Disclaimer

Powered by: newtelligence dasBlog 1.9.6264.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail