[CLOSED] Change event triggers when textfield modified in code-behind

  1. #1

    [CLOSED] Change event triggers when textfield modified in code-behind

    Hi there, I have setup a textfield on a form with a direct event triggering when field changes. I was expecting this event to trigger only when user changes the value manually on browser. Then I realized that if I change textfield value on code behind, the change trigger triggers the same. Is it there a way to disable trigger when textfield is modified at server side? I tried adding "return false;" to Before property of the event before assigning value but it did not work.
    Last edited by Daniil; Nov 27, 2013 at 3:04 AM. Reason: [CLOSED]
  2. #2
    Hi @jstifel,

    Yes, the Change event fires on any change.

    You can suspend the event on demand.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Set(object sender, DirectEventArgs e)
        {
            this.TextField1.SuspendEvent("change");
            this.TextField1.Text = "test";
            this.TextField1.ResumeEvent("change");
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:TextField ID="TextField1" runat="server">
                <Listeners>
                    <Change Handler="console.log('change');" />
                </Listeners>
            </ext:TextField>
    
            <ext:Button runat="server" Text="Set" OnDirectClick="Set" />
        </form>
    </body>
    </html>
  3. #3
    Ok, I tried to call the SuspendEvent method finding there is only available one called SuspendEvents. I tried instead using this one and everything worked OK. I guess I may be running an older version of the library which does not include the SuspendEvent method. Anyway I solved the issue. Thank you very much.
    You can close the case now.
  4. #4
    Yes, the SuspendEvent appeared not so far ago.

Similar Threads

  1. [CLOSED] Textfield Change Event in Grid Panel
    By canusr1 in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 24, 2013, 11:58 AM
  2. [CLOSED] TextArea,TextField Change Event
    By Tonic in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 26, 2013, 7:17 AM
  3. Dynamic TextField Change Event Error
    By sureshvelu in forum 2.x Help
    Replies: 0
    Last Post: Jan 05, 2013, 8:27 AM
  4. [CLOSED] Triggers created in code behind - help
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 17, 2012, 3:33 PM
  5. Replies: 7
    Last Post: Nov 25, 2010, 4:18 PM

Tags for this Thread

Posting Permissions