[CLOSED] Ext.net.DirectMethods.XXXX

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Ext.net.DirectMethods.XXXX

    If called from JS directly, what is the replacement in v3.2? it worked in v1.7.

    Thanks,
    /Z
    Last edited by Daniil; Sep 07, 2015 at 6:59 AM. Reason: [CLOSED]
  2. #2
    Hi @Z,

    Please use App.direct.DirectMethodName.
  3. #3
    I must be missing something simple. I am getting App.direct is undefined.

    ext v3.2.1

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StaticTest.aspx.cs" Inherits="Crystal.Views.Support.StaticTest" %>
    
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    
    
    
    <!DOCTYPE html>
    
    
    <html>
    <head id="Head1" runat="server">
        <title>Test</title>
    
    
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server">
                <Listeners>
                    <DocumentReady Handler="App.direct.TestDirectEvent" />
                </Listeners>
                </ext:ResourceManager>
            
           
            
            <ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout">
                <Items>
                    <ext:Panel ID="Panel1" runat="server" Region="North" Height="70">
                        <Content>
                             <h3>Test</h3>
                        </Content>
                    </ext:Panel>
                
                </Items>
            </ext:Viewport>
        </form>    
    </body>
    </html>
    code behind
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    
    using Ext.Net;
    
    
    namespace Crystal.Views.Support
    {
        public partial class StaticTest  : System.Web.Mvc.ViewPage
        {
            [DirectMethod()]
            public void TestDirectEvent(string id)
            {
                Console.Write("TEST");
            }
    
    
        }
    }
    Last edited by Z; Sep 02, 2015 at 6:00 PM.
  4. #4
    Hi Z

    The function TestDirectEvent takes id as a parameter.

    So you should pass that parameter in the function call.

    <ext:ResourceManager ID="ResourceManager1" runat="server">
        <Listeners>
            <DocumentReady Handler="App.direct.TestDirectEvent('ID123');" />
        </Listeners>
    </ext:ResourceManager>
    Also note that you actually call the function in the Handler, since Handlers contain actual JavaScript. So even if the function takes no parameters it should still be called.

    <DocumentReady Handler="App.direct.TestDirectEvent();" />
  5. #5
    Also I'm not sure if
     Console.Write("TEST");
    is going to give you any value.

    You can try replacing that with or adding

    X.Msg.Alert("Test", "Direct Event Successful").Show();
    to show a simple alert.
  6. #6
    You are correct that i should pass a parameter but javascript is not strict and will just mark the variable as undefined that is fine.

    Also, Console.log in (VS2012) will log me to console in c# so you can see the printout int he Output/Immediate window.

    The core problem is that App.direct is undefined so i must be missing something in the markup (maybe a resourcemanager flag)

    Thanks,
    /Z
  7. #7
    Hi Z

    It's true JavaScript is not strict and parameters are undefined. But in this case, you are calling a server function. So a parameter has to be passed or it will not work otherwise.

    I am suspicious that this is the cause since in my test case, not passing a parameter will not cause the function to fire. Whereas passing even an empty string will work.

    In any case, the default namespace for direct methods and controls is App. If by any chance it is changed somewhere (I doubt) you can still set it in the ResourceManager using

    Namespace="App"

    You can also set any value you want as namespace but you have to follow with all direct method calls and control references.

    So

    Namespace="MyNamespace"

    you would have to use

    MyNamespace.direct.TestDirectEvent('ID123');
  8. #8
    Tried with a param and no difference. See screenshot. look at the watch window for App.direct.

    /Z
    Attached Thumbnails Click image for larger version. 

Name:	Untitled.png 
Views:	45 
Size:	8.9 KB 
ID:	24195  
  9. #9
    Then maybe the Namespace is being overridden somewhere. Maybe in the Web.config.

    One more thing to be sure. Can you access the ViewPort using
    App.Viewport1
    ?
  10. #10
    Do you have any of the following defined in your Web.config in the <extnet> node?

    directMethodNamespace

    or

    namespace
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 8
    Last Post: Aug 15, 2014, 4:34 AM
  2. T4MVC and DirectMethods
    By aptido in forum 2.x Help
    Replies: 0
    Last Post: Jun 13, 2013, 7:18 AM
  3. App / DirectMethods Objects gone?
    By Bubu in forum 1.x Help
    Replies: 2
    Last Post: Oct 31, 2012, 12:31 AM
  4. DirectMethods Problem
    By aelen in forum 1.x Help
    Replies: 3
    Last Post: Dec 26, 2011, 5:34 AM
  5. [CLOSED] [1.0] MVC Ext.net.DirectMethods
    By alliedwallet.com in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jan 19, 2011, 10:31 PM

Posting Permissions