in
Forums
Blogs
DevExpress.com
Client Center
Support Center
DevExpress Channel

OnKeyPress Form Submits/Does Postback

Last post 8/27/2008 11:04 AM by Dan. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 8/25/2008 2:04 PM

    • Dan
    • Top 500 Contributor
    • Joined on 3/24/2008
    • Posts 58

    OnKeyPress Form Submits/Does Postback

    Hello -

    I'm having an issue where I'm trying to capture the "enter" keypress event and triggering the callback panel event for a button. Basically, the form always performs a postback even though I've captured the Enter key event. If I click the aspxButton the form behaves as expected. It validates the fields and displays appropriate messages. When the Enter Key is pressed, it validates the fields then appears to do a postback clearing out the messages. Thanks.

    ////aspxRoundPanel:////

                        <dxrp:ASPxRoundPanel ID="pnlLogin" runat="server" Width="450px" Height="200px" DefaultButton="btnLogin" ShowHeader="False" HorizontalAlign="Center" ClientInstanceName="clLogin" EnableClientSideAPI="True">

    ////aspxButton/////

                        <dxe:ASPxButton ID="btnLogin" UseSubmitBehavior="false" CausesValidation="true" runat="server" Text="Log In" ClientInstanceName="btnLogin" EnableClientSideAPI="True" AutoPostBack="False" Height="26px" Width="76px" CssFilePath="~/App_Themes/Glass/{0}/styles.css" CssPostfix="Glass" Cursor="pointer">
                            <ClientSideEvents Click="function(s, e) {
                             if(ASPxClientEdit.ValidateGroup('entryGroup')) {
                                CallbackPanel.PerformCallback(e);
                                }
                            }" />
                            <Image AlternateText="Log In" />
                            <Border BorderColor="Gray" BorderStyle="Solid" BorderWidth="1px" />
                        </dxe:ASPxButton>

    ////Here is my BLOCKED SCRIPT/////

    function checkEnter(e){ //e is event object passed from function invocation
                var characterCode //literal character code will be stored in this variable

                if(e && e.which){ //if which property of event object is supported (NN4)
                e = e
                characterCode = e.which //character code is contained in NN4's which property
                }
                else{
                e = event
                characterCode = e.keyCode //character code is contained in IE's keyCode property
                }

                if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
                alert("test");
                return false;
                }
                else{
                return false;
                }

                }

  • 8/26/2008 7:10 AM In reply to

    Re: OnKeyPress Form Submits/Does Postback

    Hi Dan,

    From your code it is not clear where the checkEnter function is called from.

    Generally, this may occur when there is a single editor (textbox, or a plain INPUT element) on the page. And this is a standard behavior of HTML forms.

    Thanks, Alexey M
    R&D, .NET Team
    Developer Express Inc.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center at http://www.devexpress.com/Support/Center
  • 8/26/2008 10:49 AM In reply to

    • Dan
    • Top 500 Contributor
    • Joined on 3/24/2008
    • Posts 58

    Re: OnKeyPress Form Submits/Does Postback

    CheckEnter is in the body tag.

    <body onkeypress="checkEnter(event)">

    I'm guessing this should be able to execute the callback function instead of actually doing a postback on the page?

     

     

  • 8/27/2008 2:28 AM In reply to

    Re: OnKeyPress Form Submits/Does Postback

    Answer

    Try this:

    <body onkeypress="return checkEnter(event)">

    Thanks, Alexey M
    R&D, .NET Team
    Developer Express Inc.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center at http://www.devexpress.com/Support/Center
  • 8/27/2008 11:04 AM In reply to

    • Dan
    • Top 500 Contributor
    • Joined on 3/24/2008
    • Posts 58

    Re: OnKeyPress Form Submits/Does Postback

    Oops. That worked. Thanks

Page 1 of 1 (5 items)
Copyright © 1998-2009 Developer Express Inc.
ALL RIGHTS RESERVED