How to make Enter key fire ASP:Button event for DropDownList control after an autopostback?

Posted on 2006-04-10
Medium Priority
Last Modified: 2012-08-13
I would like to use the Enter key to act as though a Find button was pressed. I have no problem doing this if the last field the user typed in is a text field. However, I have many DropDownList controls and I want to be able to have the user select an item from the drop-list and press Enter and have the Find button fire. Again this works just fine if the DropDownList does not have autopostback set to true. If autopostback is set to true the Enter key does nothing. If I again select the same item from the drop-list (which means the post back does not happen as it is the same item) the Enter key does act as the Find button. The Find button is an Asp:Button type. My question - How do I make the Enter key work for a DropDownList control that has posted back immediately after the post back? Thanks - David
Question by:dloendorf

Expert Comment

ID: 16423523
add the following in the command of your DropDownList control post back and see if this help, or you may try to add the javascript in the attribute of body onload in the command of your DropDownList control post back if it's not working, and remove it inside the Find_Button poastback command,

string SCRIPT = "<script type=\"text/javascript\">";
SCRIPT += this.GetPostBackEventReference(this.your_findButton);
SCRIPT += "</script>";

if (!Page.IsStartupScriptRegistered("Find")
      Page.RegisterStartupScript("Find", SCRIPT);

Accepted Solution

manojkumarps earned 2000 total points
ID: 16424985
Hello dloendorf,
            I am very sorry to say this but if you have a dropdownlist then you cannot make the enter key event to be fired for a default button unless the ficus is out of the dropdownlist.

          Microsoft still are working on it.


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question