Solved

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

Posted on 2012-03-27
2
180 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 40

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

813 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

18 Experts available now in Live!

Get 1:1 Help Now