Static Direct method with extra Parameters

  1. #1

    Static Direct method with extra Parameters

    Hi,

    I am looking to acheive something below i.e. using a Static direct method with some extra parameters but i am getting error "Member 'Ext.Net1.WebForm1.SetTimeStamp(object, Ext.Net.DirectEventArgs)' cannot be accessed with an instance reference; qualify it with a type name instead"

    <ext:Button ID="Button1" runat="server" Text="Click Me" Icon="Lightning">
                <DirectEvents>
                      <Click OnEvent="SetTimeStamp">
                            <ExtraParams>
                                <ext:Parameter  Name="RefferalIDList" Value="123456" Mode="Raw" />
                            </ExtraParams>
                        </Click>                
                 </DirectEvents>            
            </ext:Button>
    Server side
    [DirectMethod]
            public static void SetTimeStamp(object sender, DirectEventArgs e)
            {
                Ext.Net.X.Mask.Hide();
                MessageBoxConfig oConfig = new MessageBoxConfig();
                oConfig.Icon = MessageBox.Icon.QUESTION;
                oConfig.Buttons = MessageBox.Button.YESNO;
                oConfig.MessageBoxButtonsConfig = new MessageBoxButtonsConfig
                {
                    Yes = new MessageBoxButtonConfig
                    {
                        Handler = "Ext.net.Mask.show();",
                        Text = "Yes clicked."
                    },
                    No = new MessageBoxButtonConfig { Text = "No Clicked." }
                };
                Ext.Net.X.Msg.Show(oConfig);            
            }
    Last edited by Daniil; Sep 08, 2015 at 3:45 PM. Reason: Please use [CODE] tags
  2. #2
    Hi @dkhandelwal,

    DirectMethods and DirectEvents are different things.
    http://examples2.ext.net/#/Events/DirectEvents/Overview
    http://examples2.ext.net/#/Events/Di...thods/Overview

    A DirectEvent cannot be static. Also there is no need to set a [DirectMethod] attribute for that.

    A DirectMethod can be static, but it cannot be used as a DirectEvent's OnEvent. Also there is no object sender, DirectEventArgs e parameters for DirectMethods.

    You sort of mix two different approaches which is not going to work.

    For a static DirectMethod sample pleas see #4 in the DirectMethods example that I mentioned above.
  3. #3

    Can we read the value of ExtraParams on Javascript side

    Daniil Thanks for your reply. So if this is not possible can we read the value of ExtraParams on Javascript side (this will resolve my problem) ?

    <ext:Button ID="Button1" IDMode="Static" runat="server" Text="Click Me" Icon="Lightning">
                <DirectEvents>
                      <Click OnEvent="SetTimeStamp" Before="CallParam(e);" >
                            <ExtraParams>
                                <ext:Parameter  Name="RefferalIDList" Value="123456" Mode="Raw" />
                            </ExtraParams>
                        </Click>                
                 </DirectEvents>          
            </ext:Button>
    <script>
            function CallParam(e) {
                var params = e.ExtraParams;
                return false;
            }
        </script>
    Last edited by Daniil; Sep 09, 2015 at 4:04 PM. Reason: Please use [CODE] tags
  4. #4
    An extraParams arguments is passed to a DirectEvent's Before handler.

    Example
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void TestDirectEventHandler(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("DirectEvent", "Hello from Server!").Show();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script>
            var onBefore = function (component, type, action, extraParams, o) {
                console.log(extraParams);
    
                return false;
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Button runat="server" Text="Click Me">
                <DirectEvents>
                    <Click OnEvent="TestDirectEventHandler" Before="onBefore">
                        <ExtraParams>
                            <ext:Parameter Name="someParam" Value="123456" Mode="Raw" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>
  5. #5

    Thanks Daniil . This solves my problem.

    Thanks Daniil . This solves my problem.

Similar Threads

  1. Replies: 3
    Last Post: Aug 03, 2015, 4:59 PM
  2. Replies: 3
    Last Post: Apr 01, 2015, 7:36 PM
  3. [CLOSED] Extra Parameters in Textfields
    By trezv in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jul 03, 2012, 3:24 PM
  4. Listener Fn - How can I pass extra parameters?
    By lionelhutz in forum 1.x Help
    Replies: 0
    Last Post: Dec 10, 2009, 5:25 PM
  5. Extra parameters Ajax Method from a Text Field
    By davromu in forum 1.x Help
    Replies: 4
    Last Post: Jun 17, 2009, 3:27 PM

Tags for this Thread

Posting Permissions