[CLOSED] Listener fired on Databind

  1. #1

    [CLOSED] Listener fired on Databind

    I've got a checkbox control with a listener attached. The listener calls a javascript function which causes the control to become immediately disabled. However, I noticed the listener is being activated when the page first loads and the checkbox is being databound.

    What can I do to prevent this from happening?
    Last edited by Baidaly; Mar 12, 2013 at 6:34 PM. Reason: [CLOSED]
  2. #2
    Hello!

    Can you provide sample of your problem?
  3. #3
    Quote Originally Posted by Baidaly View Post
    Hello!

    Can you provide sample of your problem?
    Here's the control code for TestControl2.ascx:

    <%@ Control Language="vb" %>
    
    <script type="text/javascript">
        var toggleDCA = function () {
            alert('WTF?!');
        };
    </script>
    
     <script runat="server">    
         
         Public Overrides Sub DataBind()
             DCA.Checked = True
         End Sub
         
         Public Sub Show()
             ActionWindow.Show()
         End Sub
        
     </script>
    
    <ext:Window ID="ActionWindow" runat="server" Hidden="true" Title="Listener Test" Width="700" Height="600" Modal="true" Layout="FitLayout">
        <Items>
            <ext:Panel ID="Panel1" runat="server">
                <Items>
                    <ext:Checkbox ID="DCA" runat="server" FieldLabel="Enable">
                        <Listeners>
                            <Check Fn="toggleDCA" />
                        </Listeners>
                    </ext:Checkbox>
                </Items>
            </ext:Panel>
        </Items>
    </ext:Window>
    Here's the page code for Test2.aspx

    <%@ Page Language="vb" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Register TagPrefix="uc" TagName="ListenerTest" Src="~/TestControl2.ascx" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
        
        Protected Sub ShowControlButton_Click(sender As Object, e As DirectEventArgs)
            ListenerTest.DataBind()
            ListenerTest.Show()
        End Sub
    
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
    
        <ext:ResourceManager runat="server" />
    
    
        <ext:Viewport runat="server">
            <Items>
                <ext:Panel ID="MainPanel" runat="server" Layout="FitLayout">
                    <TopBar>
                        <ext:Toolbar runat="server">
                            <Items>
                                <ext:Button ID="ShowControlButton" runat="server" Text="Show Control" OnDirectClick="ShowControlButton_Click" />
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Content>
                        <uc:ListenerTest ID="ListenerTest" runat="server" />
                    </Content>
                </ext:Panel>
            </Items>
        </ext:Viewport>
    
    
        </form>
    </body>
    </html>
  4. #4
    Hi,

    Setting up the Checked property during a DirectEvent causes generating this script.
    checkbox.setValue(true);
    It causes the Checked event to be fired.

    To avoid the event you can use a pair of the SuspendEvents and ResumeEvents methods.
    Public Overrides Sub DataBind()
         DCA.SuspendEvents(False)
         DCA.Checked = True
         DCA.ResumeEvents()
    End Sub
  5. #5
    Quote Originally Posted by Daniil View Post
    Hi,

    Setting up the Checked property during a DirectEvent causes generating this script.
    checkbox.setValue(true);
    It causes the Checked event to be fired.

    To avoid the event you can use a pair of the SuspendEvents and ResumeEvents methods.
    Public Overrides Sub DataBind()
         DCA.SuspendEvents(False)
         DCA.Checked = True
         DCA.ResumeEvents()
    End Sub
    That worked. Thanks.

Similar Threads

  1. Replies: 2
    Last Post: Nov 26, 2012, 7:14 AM
  2. [CLOSED] Command Listener not fired on IE9
    By ddslogistics in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 05, 2012, 3:07 PM
  3. [CLOSED] Window is not fired in some computers
    By digitek in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 27, 2011, 9:52 AM
  4. Replies: 7
    Last Post: Jun 15, 2011, 7:34 PM
  5. Why store Refreshment is not fired
    By NishaLijo in forum 1.x Help
    Replies: 0
    Last Post: Oct 09, 2010, 9:38 AM

Tags for this Thread

Posting Permissions