Solved

Hiting  Enter button causes cancel button to fire..,but i want Search button to be fired..

Posted on 2012-03-27
2
178 Views
Last Modified: 2012-08-13
I have two button in Webpage
            <td class="buttonCell" " colspan="5" >      
                              <asp:button id="btnClear" CssClass="button" Text="Clear All" Runat="server"      Width="75px" OnClick="btnClear_Click" CausesValidation="False"></asp:button>
                      <asp:button id="btnSearch" CssClass="defaultbutton" Text="Search" Runat="server" Width="75px" OnClick="btnSearch_Click" AccessKey="S" CausesValidation="False"></asp:button>          
        </td>


In master page i have this jquery
   jQuery(document).keydown(function (event) {
              if (event.keyCode == 13) {
                  //not working: alert("Enter clicked.");
                  //not working: __doPostBack('__Page', 'EnteryKey');
                  //find default button.
                  var submitButton = jQuery(".defaultbutton").get(0);
                  if (submitButton != null) {
                      submitButton.click();
                  }
              }

When i hit enter button it trigger Cancel_clik event ,not search_click.
If i change the order it works find .Due to some CSS and layout issues ,i dont want to change the order.
Can any one help me .
0
Comment
Question by:hariaspind
2 Comments
 
LVL 39

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 37773309
http://forums.asp.net/t/985791.aspx/1

In your form set the default button.
0
 

Author Closing Comment

by:hariaspind
ID: 37773759
It worked for me .Thanks.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now