Blog

Most Recent Blog Entries

Feb 22

Written by: Brian Dukes
2/22/2008 10:57 AM 

When you have multiple submittable forms on a web page (such as a search and a checkout), you have to somehow let the browser know which form to submit when the user presses .  ASP.NET provides a DefaultButton property off of the Panel control, which is supposed to let you define which button to submit through if the user presses <enter> while the focus is in that panel.  However, it doesn't work in Firefox, so you have to keep searching if you're building any sort of public-facing website.

ClientAPI to the rescue!  We did a little poking around and found the RegisterKeyCapture method in DotNetNuke's ClientAPI.  This takes an input control (such as a text box), a postback control (such as a button) and an ASCII key identifier.  So, to make your search box work, it's ClientAPI.RegisterKeyCapture(txtSearch, btnSearch, 13); since 13 is the ASCII code for <enter>.  There's also an override that takes plain ol' javascript instead of a postback control.

Enjoy!

Tags:

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 

Purchase

Please click here to buy now.
Payment will be processed via PayPal.

Test Drive!

Want to find out how it works? Visit our demo site to see the modules in actions!

Subscribe

Sign up for our newsletter and get the latest product updates!

Online Support

Powered by DotNetNuke