MVC :: 2 - Set Default Button For "Enter" Key

Nov 1, 2010

I have the following code in a View:

[Code]....

How do I set the "Login" button as the default button for when the "Enter" key is clicked on the keyboard?

View 27 Replies


Similar Messages:

Web Forms :: 2.0 - Set Focus To A TextBox While Button Click Event Is Fired Using Default Button When Enter Key Is Pressed

Mar 25, 2010

How can I set Focus to a TextBox while Button click event is fired using Default Button when enter key is pressed. Here is my Page and code.

<%@ Page Title="" Language="C#" MasterPageFile="~/mpChat.master" AutoEventWireup="true" CodeFile="FocusTest.aspx.cs" Inherits="FocusTest" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" DefaultButton="Button1">
<asp:TextBox ID="TextBox1" runat="server">
</asp:TextBox>
<asp:Button ID="Button1"
runat="server" Text="Button" onclick="Button1_Click" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
using System;
public partial class FocusTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
TextBox1.Focus();
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox1.Focus();
}
}

View 1 Replies

Web Forms :: How To Set Enter Key As Default Key For Particular Button

Dec 7, 2010

i have a page with search text box and button ,, when i search by clicking on the button with mouse its working fine But when i am enter the keywords and hitting enter the page getting reloaded.. can have solution for this.

View 2 Replies

Web Forms :: Default Enter Button For Aspx Page?

May 17, 2010

Im using Masterpage with my asp.net application now i want to set enter for my button..

View 1 Replies

AJAX :: Auto - Complete Extender And Default Button Of A Panel - Enter Key

Sep 25, 2010

I have a text box with an auto-complete extender attached to it. This is in a panel. Now, I have set the default button of the panel to the submit button of the panel.

<panel>
<text box/>
<autocompleteextender/>
<button/>
</panel>

Now, I find that when the auto-complete options show up and I try to select an option using the enter key, the button is pressed (triggering a postback) due to it being the defaultbutton of the panel. I want to be able to select an aut-complete option using the enter key and yet not post back. Therefore, the enter key (when the text box is in focus) should not trigger a postback. How can I achieve this?

View 1 Replies

Forms Data Controls :: Enter Key Will Not Click The Form's Default Button On Mobile Browser, IE Mobile 5.0

Aug 10, 2010

I am developing a web based application for a Motorolla Mc 9090, it is a wireless barcode scanner running windows mobile 5.0.

The idea is to centralize the inventory in one database, by scanning items, serials, bins etc.

I have a set of pages each containg forms, where the user will have to scan an item, and automaticall the scanner has a carriege return (ENTER key) the idea was to have the user simply scan, and the page would automatically click the button posting to server for processing and then the server would reply.

For some reason i cannot get the focus() to work as well as the defaultbutton propperty of the form. There is also 1 more problem, the readOnly textboxes look the same as the non readOnly textboxes, even with the backcolor property changed.(guessing this is just MS)

View 3 Replies

Web Forms :: How To Create Default Enter Key Event

Jul 23, 2010

I create a new project, add a textbox and a button (and its click event), and run the app. If I press enter while the focus is inside the textbox, it posts back, but the button's click event isn't fired. What makes sense is the button's click event isn't fired, because I didn't specify "defaultbutton" for the form. What doesn't make sense is why the page is posted back. I thought maybe if I set "AutoPostBack" to false that it would change something (wishful thinking), but that didn't work.ion

View 6 Replies

C# - Default LinkButton On Enter In A Master Page Cannot Work

Dec 7, 2010

I looked through and through and found no clean solution for this. A colleague of mine did find a pretty dirty solution but I don't see why the solutions in the links reference below does not work when I place it in a master page. I have a master page that basically has a textbox and a linkbutton, when I hit the enter key, the default button for the child page gets called instead.

http://weblogs.asp.net/jeff/archive/2005/07/26/420618.aspxset linkbutton as asp:panel in asp.net

View 2 Replies

Web Forms :: Trying To Do Is Validate The Input Only When The Enter Button Is Clicked Not The Search Button?

Dec 7, 2010

I have a asp page with tow buttons search adn enter and asp required field validator in it, what I am trying to do is validate the input only when the enter button is clicked not the search button, right now when the search button is clicked it validates and throws an error.

View 2 Replies

Set Button Focus Off When Pressing Enter

Dec 2, 2010

i am using master page i have in my left menu there is a button to logout on the left menu when i click on it i was typing inside a textbox and but whenever i press Enter it logs me out i think because it s causing the click on buttonlogout how to avoid this problem in all my pages but i don t want to disable the press enter only i need to stop it on log outbutton from left menu it seems i have to set focus off on this button.

View 8 Replies

Specific Button Click With Enter?

Sep 4, 2010

i want a specific button be pushed and go to the sub that handles this button click when enter is pushed can be that done?

View 7 Replies

Web Forms :: Enter Button Does Not Work?

Dec 24, 2010

I have a "contact us" page that I am working on. It works fine when you click the Submit button with a mouse. However, nothing happens when I press the "enter key". I have the page wrapped in a panel, with btnSubmit selected as the default button. How do I make the "enter key" work when pressed? Here is the code:

[Code]....

View 2 Replies

C# - Preventing A Button From Responding To 'Enter'?

May 13, 2010

I have a master template that all the pages on my site use. In the template there is an empty panel. In the code-behind for the page an imagebutton is created in the panel dynamically in my Page_Load section (makes a call to the DB to determine which button should appear via my controller). On some pages that use this template and have forms on them, pressing the Enter key fires the click event on this imagebutton rather than the submit button in the form. Is there a simple way to prevent the imagebutton click event from firing unless it's clicked by the mouse? I'm thinking a javascript method is a hack, especially since the button doesn't even exist in the master template until the button is dynamically created on Page_Load (this is ugly since I can't simply do <% =btnName.ClientId %> to refer to the button's name in my aspx page).I tried setting a super-high tabindex for the image button and that did nothing. Also set the button to be the DefaultButton in its panel on the master template but that did not work either. Moreover, I don't want to add a property to all of my pages that use this template (there are hundreds). It would be optimal to find a solution that works globally from my master template.I'll try to show our example here:We have a button on the top of each page in our system that lets you star the page as one of your favorites, sort of a server-side bookmark system. When the page loads it looks to see if the page is one of your favorites or not and then shows a gold star if it is, and a gray star if it is not. Clicking the imagebutton of a star toggles the page favorite status.In my master template (FullMenu.master) I have this panel

<asp:Panel runat="server" ID="pnlFavorite" style="display:inline;"></asp:Panel>

Next there is a class which creates the button and adds it to the panel on the master template:

public void InsertStarButton()
{
CreateStarButton();

[code]....

View 2 Replies

Button Onclick Event With The Enter Key Press?

Mar 25, 2010

Have a form with a button and some text fields on it.When I hit enter after filling a field the event for the button fires up event onClick.How can I get around this since on one of the fields I have a textchangeEvent I to fire up.

View 5 Replies

Enter Button Navigates Page Back?

Jul 6, 2010

I have a search field (text box) at the top of my page. When you type something, and press enter, the page navigates back to the previous page? What I want it to do is act as if I clicked the Search button.

View 5 Replies

Webforms - Search Field Enter Button

Feb 10, 2011

I have a web page with 3 search fields on it, each with a different submit button. When using the enter button on the keyboard to submit any of them, an incorrect action is being performed, although with the mouse it's fine. Any ideas why this is happening? The rendered HTML as requested below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="ctl00_ctl00_Head1">
<body id="home">
<form name="aspnetForm" method="post" action="history_lookup.aspx?theme=t2" id="aspnetForm">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE1MzkzOTQxNDBkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYFBSZjdGwwMCRjdGwwMCRNaW5pQ2FydFRleHQxJEltYWdlQnV0dG9uMQUsY3RsMDAkY3RsMDAkVG9wTmF2JFF1aWNrU2VhcmNoMSRJbWFnZUJ1dHRvbjIFLGN0bDAwJGN0bDAwJFRvcE5hdiRRdWlja1NlYXJjaDEkSW1hZ2VCdXR0b24xBShjdGwwMCRjdGwwMCRjcGhSb290JGNwaFN1Yk1hc3RlciRzdWJtaXQxBShjdGwwMCRjdGwwMCRjcGhSb290JGNwaFN1Yk1hc3RlciRzdWJtaXQy4UTdoX+Ej1GFsXGOrI898SMftDA=" />
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<script src="/WebResource.axd?d=gfGwAOwAxcQ9Nlq6l3EJfg2&t=634166396192656250" type="text/javascript"></script>
<div>
<input type="hidden" name="__PREVIOUSPAGE" id="__PREVIOUSPAGE" value="fwZ-2v_x8CYGGr9a8Ce0s6gkE38QmubHNljKJaKxZV41" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWCAKs3Nu8DwLV2a2zBwKK/6PwCQLBpvyBBAKT+aizBgL+qMTTDwLU1/SWCwL+qNiuCArtGFkuC9Zj3X3If1cwPC7PKtcm" />
</div>
<div class="container clearfix" style="left: 0px; top: 0px">
<div class="utilityNav">
<a class="MenuItem" href="/extranet.aspx?theme=t2" title="Account Info">
Account Info
</a>
|
<a class="MenuItem" href="/history_lookup.aspx?theme=t2" title="Order History">
Order History
</a>
|
<a class="MenuItem" href="/_user_logout.aspx" title="Sign Off">
Sign Off
</a>
</div>
<div class="header">
<div class="cart" >
<div id="menu">
<div class="cartimage">
<input type="image" name="ctl00$ctl00$MiniCartText1$ImageButton1" id="ctl00_ctl00_MiniCartText1_ImageButton1" src="images/bg-cart-corner.gif" align="left" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl00$MiniCartText1$ImageButton1", "", false, "", "cart.aspx", false, false))" style="border-width:0px;" />
</div>
<div class="cartlabel">Checkout Cart:<br />
<a id="ctl00_ctl00_MiniCartText1_lbMiniCart2" class="cartlink" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl00$MiniCartText1$lbMiniCart2", "", false, "", "cart.aspx?theme=t2", false, true))">View your cart</a>
</div>
<br /><br />
</div>
</div>
</div>
<div class="primaryNav">
<div class="navdropdown">
</div>
<div align="right" class="quicksearch">
<div class="QuickSearch">
<div id="ctl00_ctl00_TopNav_QuickSearch1_quicksearchpanel" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'ctl00_ctl00_TopNav_QuickSearch1_ImageButton1')">
<table cellpadding="0" cellspacing="0" class="QuickSearch">
<tr>
<td class="quicksearch_text">
<span id="ctl00_ctl00_TopNav_QuickSearch1_lblSearch"></span>
</td>
<td >
<input class="QuickSearch" type="text" name="searchstring" size="15" maxlength="30" value="Search" onfocus="if (this.value == 'Search') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search';}" />
</td>
<td class="quicksearch_button">
<input type="image" name="ctl00$ctl00$TopNav$QuickSearch1$ImageButton2" id="ctl00_ctl00_TopNav_QuickSearch1_ImageButton2" src="images/searchbutton.gif" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl00$TopNav$QuickSearch1$ImageButton2", "", false, "", "/Searchdh.aspx?theme=t2", false, false))" style="border-width:0px;" />
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<td valign="top">
<div class="HistoryLookupPage">
<h1 class="PageHeader">
<span id="ctl00_ctl00_cphRoot_cphSubMaster_PageHeader1_LabelHeader">Order History</span>
</h1>
<p>
Enter the reference number of the order you want to see.
</p>
<p>
Reference number
<input name="ctl00$ctl00$cphRoot$cphSubMaster$CustomerReference" type="text" id="ctl00_ctl00_cphRoot_cphSubMaster_CustomerReference" class="borderTextBox" />
<input type="image" name="ctl00$ctl00$cphRoot$cphSubMaster$submit1" id="ctl00_ctl00_cphRoot_cphSubMaster_submit1" src="images/buttons/findorder-blue.gif" style="border-width:0px;" />
</p>
<br />
<p><b>Or search by PO Number</b></p>
<p>
<input name="ctl00$ctl00$cphRoot$cphSubMaster$CustomerReference2" type="text" id="ctl00_ctl00_cphRoot_cphSubMaster_CustomerReference2" class="borderTextBox" />
<input type="image" name="ctl00$ctl00$cphRoot$cphSubMaster$submit2" id="ctl00_ctl00_cphRoot_cphSubMaster_submit2" src="images/buttons/findorder-blue.gif" style="border-width:0px;" />
</p>
</div>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
and the aspx markup
<%@ Import Namespace="System.Configuration.ConfigurationManager" %>
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="history_lookup.aspx.vb"
EnableViewState="false" Inherits="history_lookup" ValidateRequest="false" CodeFileBaseClass="Main.Page"
MasterPageFile="~/masters/default/main.master" RuntimeMasterPageFile="ThreeColumn.master"
CrumbName="<%$ Resources: Language, LABEL_MENU_HISTORY %>" %>
<%@ Register Src="~/controls/Message.ascx" TagName="Message" TagPrefix="uc1" %>
<%@ Register Src="~/controls/PageHeader.ascx" TagName="PageHeader" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphSubMaster" runat="Server">
<td valign="top">
<div class="HistoryLookupPage">
<uc1:Message ID="Message1" runat="server" />
<uc1:PageHeader ID="PageHeader1" runat="server" Text="<%$ Resources: Language, LABEL_MENU_HISTORY %>"
EnableTheming="true" />
<p>
<asp:Literal ID="Literal1" runat="server" Text="<%$ Resources: Language, LABEL_PLEASE_ENTER_ORDERREF %>"></asp:Literal>
</p>
<p>
<asp:Literal ID="Literal2" runat="server" Text="<%$ Resources: Language, LABEL_HISTORY_LOOKUP %>"></asp:Literal>
<asp:TextBox runat="server" ID="CustomerReference" CssClass="borderTextBox" />
<%-- <asp:Button ID="Button1" runat="server" CssClass="BtnC" Text="<%$ Resources: Language, ACTION_LOOKUP %>" />
--%> <asp:ImageButton ID="submit1" runat="server" imageurl="~/images/buttons/findorder-blue.gif" />
</p>
<% if Not globals.User("Anonymous") then %>
<br />
<p><b>Or search by PO Number</b></p>
<p>
<asp:TextBox runat="server" ID="CustomerReference2" CssClass="borderTextBox" />
<%-- <asp:Button ID="Button2" runat="server" CssClass="BtnC" Text="Find Order" />
--%> <asp:ImageButton ID="submit2" runat="server" imageurl="~/images/buttons/findorder-blue.gif" />
</p>
<% end if %>
</div>
</td>
</tr>
</table>
</asp:Content>

View 1 Replies

How To Enter Key Triggers Wrong Submit Button

Feb 23, 2011

I am working on an mvc application. Two tables each have their individual submit button. Table1 has default submit on enter key. How do I change the submit button based on textbox focus?

<table>
...<td align="left"><%= Html.TextBox("name")%></td>
...<input id="nameSubmit" name="NameSubmit" type="submit" value="Search"/>
</table>
<table>
...<td align="left"><%= Html.TextBox("idNum")%></td>
...<input id="idSubmit" name="IdSubmit" type="submit" value="Search"/>
</table>

I tried using the panel, but "the DefaultButton of 'Panel1' must be the ID of a control of type IButtonControl".

View 1 Replies

Enter Key Press For Submit Button Click?

Mar 24, 2011

I have an AJAX PopupExtender that popsup a panel with submit button. I want to recognise the enter key press as the click event for the submit buttNeed to set the form property called "AcceptButton" to this button to achieve this functionality. I have two popups with a submit button on each of them. How to set this behaviour ?

View 3 Replies

Defaultbutton - Enter Key In C# Firing Wrong Button?

Aug 12, 2010

I have a text box and many buttons. When user is in some text box and presses the "enter" key then specific button click event is raised. I read on the internet that there are some problems with the "enter" key and I tried few solutions but still it always enters that button event (that button is the first button in the page).

I tried creating a button which does nothing and writing this in the page_load:

idTextBoxFA.Attributes.Add("onkeydown","if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementBtId('" + noEnterButton.UniqueID + "').click();return false;}} else {return true}; ");

All my page controls are in a form and I tried giving the form "defaultButton" property to that button I created. That didnt work either.

View 1 Replies

User Controls :: How To Use Enter Key Instead Of Button For Search

May 7, 2015

Instead of clicking button ,How Enter Key Works??

Type Something in TextBox and Press Enter and result appear without Clicking any button , How??

View 1 Replies

Web Forms :: Enter Key Button Press Not Working In FireFox?

Jan 17, 2010

I have to set enter key event to text box, it work fine in IE, but not in firefox.

Here my code:

function DoClickToButton() {
var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
alert(keycode);
if (keycode == 13) {
document.getElementById('<%=Button1.ClientID %>').click(); return false;
}
else {
return true
};
}

View 6 Replies

Web Forms :: Allow User To Press Enter Key To Select Button?

Jan 15, 2010

[Code]....

View 8 Replies

Web Forms :: On Enter Key Press Button Click Should Fire?

May 18, 2010

How can one fire a button click event when someone presses Enter in Textbox. I had a master page on which Search button & a Textbox for writing Search text is there. When one clicks on "Search" button, it works fine. But when one presses Enter, no search results are displayed.

View 3 Replies

Adding Javascript So It Would Recognize The Button And Allow Users To Hit Enter

Mar 1, 2010

I am having trouble with something, my client wants to be able to hit <enter> as well as click the button on this page:-

[URL]

If you look at the Blue "Postcode search" and try searching for a nursery byb clicking the button you will see how it works. However then try doing the same but hitting <enter> and see what happens..

The front end html is as follows:-

PHP Code:

[code]....

I tried adding javascript so it would recognize the button and allow users to hit enter but this did not work.

View 7 Replies

Web Forms :: Set Enter Key Button For Gridview Footer Template?

Sep 7, 2010

[URL]

I have used the above grid view in my application ... Its working good, no problem.

Upon clicking the Addnewrowbutton, it uses to create a new row dynamically.

What i need is, new row should also be created dynamically, upon pressing enter key in the last textbox on a particular gird view row. User always can't go and click addnewrowbutton every time to create new row. Instead of it, user can press enter in the last textbox on a particular grid view row to create new row.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved