[CLOSED] DirectEvents call method codebehind

  1. #1

    [CLOSED] DirectEvents call method codebehind

    hi, how to call a server method from client side? (DirectEvents)
    Last edited by geoffrey.mcgill; Sep 08, 2011 at 6:04 PM. Reason: [CLOSED]
  2. #2
    rnfigueira, as far as I know you are not supposed to call DirectEvents from javascript. For this purpose DirectMethods were created.

    Recently I had to implement a callback to be called after a drag from a MultiSelect to a GridPanel. In order to achieve that I had to use a "notifyDrop" javascript function, which called a DirectMethod like this:

    <script type="text/javascript">
        var notifyDrop_GruposUsuario = function (ddSource, e, data) {
            // etc...
    
            Ext.net.DirectMethods.InserirUsuarioEmGrupos(codGrupos, {
                success: function(result) {
                    Ext.each(data.records, function(record) {
                        addRow(Store_GruposUsuario, record, ddSource);
                    });
                },
                failure: function(errorMessage) {
                    Ext.Msg.alert('Falha', errorMessage);
                },
                eventMask: {
                    showMask: true,
                    msg: 'Aguarde...',
                    minDelay: 500,
                    customTarget: 'GridGruposUsuario'
                }
            });
    </script>
    and in my .aspx.cs file I have the 'InserirUsuarioEmGrupos' function defined:
        [DirectMethod]
        public string InserirUsuarioEmGrupos(string grupos_json)
        {
            // ...
        }
    Consider taking a look at DirectMethods in the Ext.NET Examples Browser.
  3. #3
    Hi rnfigueira,
    Is arkilus suggestion enough for you? Do you need additional assistance?
  4. #4
    ok, thank you
  5. #5
    sorry, I have one more question. How do I call this code (notifyDrop_GruposUsuario) from button that is outside of my GridPanel?
  6. #6
    Sorry, i don't understand last post, please provide more details
    Any javascript method can be called by its name
  7. #7
    sorry I have not explained the matter well. The situation is as follows. I need to call a method that is the Parent. example:
    page1.aspx call page2.asp

    page1.aspx
    ..
    <script runat="server">
        [DirectMethod]
        public void LogCompanyInfo(string name, int count)
        {
            string template = string.Concat("{0} has approximately {1} employees.");
            string[] employees = new string[4] { "1-5", "6-25", "26-100", "100+" };
            
            this.Label3.Text = string.Format(template, name, employees[count]);
        }
    </script>
    ..
    page2.aspx - here I want to call the method of LogCompanyInfo page1
    ..
    <ext:Button runat="server" Text="Submit">
        <Listeners>
            <Click Handler="?????? Ext.net.DirectMethods.LogCompanyInfo('Ext.NET, Inc.', 0);" />
        </Listeners>
    </ext:Button>
    ..
  8. #8
    Try this
    <Click Handler="parent.Ext.net.DirectMethods.LogCompanyInfo('Ext.NET, Inc.', 0);" />
  9. #9
    The following sample should be interested for you
    https://examples1.ext.net/#/Panel/Ba...Communication/

Similar Threads

  1. Replies: 0
    Last Post: Jun 06, 2012, 7:38 PM
  2. [CLOSED] Call other window's method
    By FAS in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Mar 14, 2012, 4:03 PM
  3. Replies: 4
    Last Post: Sep 26, 2011, 2:59 PM
  4. [CLOSED] Global Static variables usage in DirectEvents Method
    By ogokgol in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 04, 2011, 2:35 PM
  5. method call
    By mono in forum 1.x Help
    Replies: 1
    Last Post: Mar 09, 2009, 6:46 AM

Posting Permissions