Behaviors when "Enter" is pressed
Behaviors when "Enter" is pressed
On my basket page (amongst others), I've noticed that no matter where the cursor is focused, the default behavior of an Enter press is to run the Search control. I know that customers will be confused when they are trying to either enter a coupon code or estimate their shipping, and instead get a search results page.
Any ideas on this? If this helps, I've noticed that the shipping estimator works with an Enter press, but only in Internet Explorer (not firefox). The coupon code box does not work on either browser with an enter press.
Thanks for the help!
Scott
Any ideas on this? If this helps, I've noticed that the shipping estimator works with an Enter press, but only in Internet Explorer (not firefox). The coupon code box does not work on either browser with an enter press.
Thanks for the help!
Scott
-
- Lieutenant, Jr. Grade (LT JG)
- Posts: 26
- Joined: Sat May 24, 2008 3:45 pm
Re: Behaviors when "Enter" is pressed
I also notice this in Firefox under Administration > Catalog -> Search This Categoryheinscott wrote:On my basket page (amongst others), I've noticed that no matter where the cursor is focused, the default behavior of an Enter press is to run the Search control. I know that customers will be confused when they are trying to either enter a coupon code or estimate their shipping, and instead get a search results page.
Any ideas on this? If this helps, I've noticed that the shipping estimator works with an Enter press, but only in Internet Explorer (not firefox). The coupon code box does not work on either browser with an enter press.
Thanks for the help!
Scott
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: Behaviors when "Enter" is pressed
There is some code in the PageHelper.cs that you might be able to adapt/use. I just haven't researched it.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Re: Behaviors when "Enter" is pressed
you could try something like the following
Code: Select all
PageHelper.SetDefaultButton(KeepShoppingButton, KeepShoppingButton.ClientID);
KeepShoppingButton.Focus();
Re: Behaviors when "Enter" is pressed
Where exactly would I use that code? I tried pasting, for instance:
PageHelper.SetDefaultButton(ApplyCouponButton, ApplyCouponButton.ClientID);
into the Page_Load section of my Conlib/CouponDialog.ascx.cs.
Didn't do anything differently for me.
Thanks,
Scott
PageHelper.SetDefaultButton(ApplyCouponButton, ApplyCouponButton.ClientID);
into the Page_Load section of my Conlib/CouponDialog.ascx.cs.
Didn't do anything differently for me.
Thanks,
Scott
Re: Behaviors when "Enter" is pressed
I figured out that if you wrap all the page elements in an <asp:panel> and apply a default button for the panel, that pressing Enter will produce the desired results. But only in Internet Explorer. Firefox still pulls the search (or, first button on the page). Any more ideas for me?
Thanks,
Scott
...BTW, it seems that ClientId is not a valid property of a LinkButton. If I change to an Asp:Button, behavior works correctly (in firefox), but looks terrible. Any idea of how to get the ClientId of a LinkButton so that Setting the default button will work??
Thanks,
Scott
...BTW, it seems that ClientId is not a valid property of a LinkButton. If I change to an Asp:Button, behavior works correctly (in firefox), but looks terrible. Any idea of how to get the ClientId of a LinkButton so that Setting the default button will work??
Re: Behaviors when "Enter" is pressed
Okay. I finally figured out a solution that seems to work, at least for now (unless someone gives me an easier one).
First, make sure that all input elements and buttons that need a default button behavior associated with them are wrapped in an asp:Panel, setting the DefaultButton="HiddenButtonInQuestion"...
The HiddenButtonInQuestion should be a regular <asp:Button>, where its OnClick fires the same event as the <asp:LinkButton>. Since an asp:Button will not fire when it contains: Visible="false", instead include the line:
style="visibility:hidden". So, essentially you will have something like:
This does seems like a lot of work to go through for such a small thing, so, if anyone has a better solution, I would love to implement it!
Thanks for the help.
Scott
First, make sure that all input elements and buttons that need a default button behavior associated with them are wrapped in an asp:Panel, setting the DefaultButton="HiddenButtonInQuestion"...
The HiddenButtonInQuestion should be a regular <asp:Button>, where its OnClick fires the same event as the <asp:LinkButton>. Since an asp:Button will not fire when it contains: Visible="false", instead include the line:
style="visibility:hidden". So, essentially you will have something like:
Code: Select all
<asp:Panel ID="CouponPanel" runat="server" DefaultButton="HiddenCouponButton">
<div class="section">
<div class="header">
<h2><asp:Localize ID="Caption" runat="server" Text="Coupon or Promotional Code" EnableViewState="false"></asp:Localize></h2>
</div>
<div class="onePageCheckoutCell2">
<asp:Label ID="InvalidCouponMessage" runat="server" Text="Invalid coupon code.<br /><br />" Visible="false" SkinID="ErrorCondition" EnableViewState="false"></asp:Label>
<asp:Label ID="NotCombineCouponRemoveMessage" runat="server" Text="The coupon {0} can not be combined with other coupons. Coupons {1} have been removed.<br /><br />" Visible="false" SkinID="ErrorCondition" EnableViewState="false"></asp:Label>
<asp:Label ID="CombineCouponRemoveMessage" runat="server" Text="The coupon {0} can not be combined with coupon {1}. Coupon {2} has been removed.<br /><br />" Visible="false" SkinID="ErrorCondition" EnableViewState="false"></asp:Label>
<asp:Label ID="ValidCouponMessage" runat="server" Text="Coupon accepted.<br /><br />" Visible="false" SkinID="GoodCondition" EnableViewState="false"></asp:Label>
<asp:TextBox ID="CouponCode" runat="server" Width="110px" MaxLength="100" EnableViewState="false"></asp:TextBox>
<asp:LinkButton ID="ApplyCouponButton" runat="server" Text="Apply" OnClick="ApplyCouponButton_Click" CausesValidation="false" EnableViewState="false" SkinID="Button" />
<asp:Button ID="HiddenCouponButton" runat="server" style="visibility:hidden" OnClick="ApplyCouponButton_Click" CausesValidation="false" EnableViewState="false" />
</div>
</div>
</asp:Panel>
Thanks for the help.
Scott
-
- Lieutenant, Jr. Grade (LT JG)
- Posts: 28
- Joined: Mon Sep 24, 2007 4:10 pm
- Location: Fort Collins, CO
Re: Behaviors when "Enter" is pressed
I was having a similar - *very annoying* - problem in the admin tool. When I am editing the textareas for a product, if I hit "enter" - instead of inserting a carriage return, the page was submitting.
I looked at the code behind and commented out one line of code and it works as I would expect it to.
in /Admin/Products/EditProduct.aspx.cs
Line # 34
// Page.Form.DefaultButton = SaveButton.UniqueID;
I don't know how many other pages have default buttons set in this way, but it could help resolve some similar issues.
I looked at the code behind and commented out one line of code and it works as I would expect it to.
in /Admin/Products/EditProduct.aspx.cs
Line # 34
// Page.Form.DefaultButton = SaveButton.UniqueID;
I don't know how many other pages have default buttons set in this way, but it could help resolve some similar issues.
Re: Behaviors when "Enter" is pressed
I did a custom page and I tried PageHelper.SetPageDefaultButton, - that worked on IE and Chrome, but not Firefox.
Then I used PageHelper.PreventFirefoxSubmitOnKeyPress which didn't work. Only when I made a hidden button with the same Onclick value and assigned it as default button it worked - just as heinscott suggested almost five years ago.
Thank you,
Then I used PageHelper.PreventFirefoxSubmitOnKeyPress which didn't work. Only when I made a hidden button with the same Onclick value and assigned it as default button it worked - just as heinscott suggested almost five years ago.
Thank you,