[CLOSED] EventMask for button click not blocking button when enter key is pressed

  1. #1

    [CLOSED] EventMask for button click not blocking button when enter key is pressed

    I'm facing the following problem in my application: I have a login page, in which there is a button with a click directevent. This direct event calls a method in which, if the user's name and password are correct, i redirect him to the main page of the website. For this directevent i use eventmask, so when the focus is on the button and the user presses enter, the button should not fire it's click direct event again until there is a response from the server. There is the problem: if the user presses enter with the focus on the button a lot of times very rapidly (or if you press enter holding it with focus on the button), the event is fired a lot of times, generating a lot of requests, and then user is presented with an error screen (only in firefox) for a brief moment, before he finally gets redirected. Here is the error screen:

    Click image for larger version. 

Name:	ErrorCommunication.jpg 
Views:	170 
Size:	15.0 KB 
ID:	1887

    And here is a piece of code to reproduce it. Just hold enter above the button, and the error message will be shown for a few seconds before the page finally gets redirected to google, in the case of the example:

    <%@ Page Language="C#" AutoEventWireup="true"%>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
        protected override void OnLoad(EventArgs e)
        {
            btDirectEvent.Focus();
            btDirectEvent.DirectEvents.Click.Event += new ComponentDirectEvent.DirectEventHandler(Click_Event);
            btDirectEvent.DirectEvents.Click.EventMask.ShowMask = true;        
            base.OnLoad(e);
        }
    
        void Click_Event(object sender, DirectEventArgs e)
        {
            
            Response.Redirect("http://www.google.com");
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
            <ext:ResourceManager ID="ResourceManager" runat="server" />
            <ext:Button runat="server" ID="btDirectEvent"></ext:Button>
        </div>
        </form>
    </body>
    </html>
    There is another problem, that would be hard to reproduce, so i'm not sending an example reproducing it: In both my login and my main page (the page to which the user is redirected after logging in, i call the following piece of code, to change the style to gray:

    Session["Ext.Net.Theme"] = Ext.Net.Theme.Gray;
    Then, in my main page, i have a menu. When one of the items of the menu is clicked, i load a page as a frame into a tabpanel. Both the pages shown in the tabpanel and the menu, when the error described above NOT happens, are shown with the correct gray style, since they're in the same session. When, and only when, the above error happens, the menu is loaded with the correct gray style, but the pages loaded in the tabpanels are loaded with the default blue style, don't know why. It's not losing the session, because i use more stuff of the session in these pages, and they are loaded normally, the only problem being the wrong blue style.

    The error screen is shown only in firefox, but i guess the error happens in IE8 also. The problem with the style happens in both browsers.

    Please, tell me if i didn't make myself clear.
    Last edited by Daniil; Nov 22, 2010 at 11:22 PM. Reason: [CLOSED]
  2. #2
    Hi Pablo,

    Regarding the first question.

    I would suggest you to disable button in the Click's listener and to enable it in DirectEvent's success handler.

    Example
    Button1.DirectEvents.Click.Success = Button1.ClientID + ".enable();";
    ...
    <ext:Button ID="Button1" runat="server">
        <Listeners>
            <Click Handler="this.disable()"/>
        </Listeners>
    </ext:Button>
  3. #3
    Button1.DirectEvents.Click.Success = Button1.ClientID + ".enable();";
    Where i call this?
  4. #4
    In the OnLoad handler.

    Example
    protected override void OnLoad(EventArgs e)
    {
        btDirectEvent.DirectEvents.Click.Event += Click_Event;
        btDirectEvent.DirectEvents.Click.EventMask.ShowMask = true;
        btDirectEvent.DirectEvents.Click.Success = btDirectEvent.ClientID + ".enable();";
        base.OnLoad(e);
    }
  5. #5
    Quote Originally Posted by Pablo Azevedo View Post
    There is another problem, that would be hard to reproduce, so i'm not sending an example reproducing it: In both my login and my main page (the page to which the user is redirected after logging in, i call the following piece of code, to change the style to gray:

    Session["Ext.Net.Theme"] = Ext.Net.Theme.Gray;
    Then, in my main page, i have a menu. When one of the items of the menu is clicked, i load a page as a frame into a tabpanel. Both the pages shown in the tabpanel and the menu, when the error described above NOT happens, are shown with the correct gray style, since they're in the same session. When, and only when, the above error happens, the menu is loaded with the correct gray style, but the pages loaded in the tabpanels are loaded with the default blue style, don't know why. It's not losing the session, because i use more stuff of the session in these pages, and they are loaded normally, the only problem being the wrong blue style.

    The error screen is shown only in firefox, but i guess the error happens in IE8 also. The problem with the style happens in both browsers.

    Please, tell me if i didn't make myself clear.
    Hi,

    Unfortunately, we have no idea what can be wrong without reproducing.

Similar Threads

  1. [CLOSED] When button click, open the menu of button
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 22, 2012, 4:23 PM
  2. Replies: 1
    Last Post: May 25, 2011, 5:06 PM
  3. [CLOSED] Make enter key activate button click direct event
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 15, 2010, 6:02 PM
  4. [CLOSED] How to know if an image button is pressed = true using javascript?
    By flormariafr in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 25, 2010, 8:20 PM
  5. [CLOSED] [1.0] Issue detecting pressed button state
    By edigital in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 29, 2010, 4:21 PM

Posting Permissions