[CLOSED] DirectMethod not working in Ext.Net.MVC5 version 4.8.1 example

  1. #1

    [CLOSED] DirectMethod not working in Ext.Net.MVC5 version 4.8.1 example

    Hi there,

    We recently purchased an upgrade of Ext.Net.MVC and started the process of migrating an old Ext app to the newest version.
    I noticed almost immediately that DirectMethods are not working. In order to reproduce the issue I created a new VS project, updated all nuget packages and then installed the lastest version of Ext.Net.MVC5. Then I copy pasted some code from the DirectMethod example on the examples page:


    then when I go into the View and click on the button, I notice a JS exception:

    Uncaught TypeError: Cannot read property 'Events' of undefined
    at ctor.handler (ext.axd?66dc2f9b29c0…d8c07c61ad54c0d68:2)
    at Object.callback (ext.axd?v=4.8.1:20)
    at ctor.fireHandler (ext.axd?v=4.8.1:20)
    at ctor.onClick (ext.axd?v=4.8.1:20)
    at ctor.fire (ext.axd?v=4.8.1:20)
    at ctor.fire (ext.axd?v=4.8.1:20)
    at ctor.publish (ext.axd?v=4.8.1:20)
    at ctor.publishDelegatedDomEvent (ext.axd?v=4.8.1:20)
    at ctor.doDelegatedEvent (ext.axd?v=4.8.1:20)
    at ctor.onDelegatedEvent (ext.axd?v=4.8.1:20)
    handler @ ext.axd?66dc2f9b29c0…d8c07c61ad54c0d68:2
    callback @ ext.axd?v=4.8.1:20
    fireHandler @ ext.axd?v=4.8.1:20
    onClick @ ext.axd?v=4.8.1:20
    fire @ ext.axd?v=4.8.1:20
    fire @ ext.axd?v=4.8.1:20
    publish @ ext.axd?v=4.8.1:20
    publishDelegatedDomEvent @ ext.axd?v=4.8.1:20
    doDelegatedEvent @ ext.axd?v=4.8.1:20
    onDelegatedEvent @ ext.axd?v=4.8.1:20

    this is the view:

    @using Ext.Net;
    @using Ext.Net.MVC;
        Layout = null;
    <!DOCTYPE html>
        <title>Ext.NET MVC Sample</title>    
        @using (Html.BeginForm())
            @Html.X().Button().Text("Click Me").Icon(Icon.Lightning).Handler("App.direct.Events.SetTimeStamp();")
            <br />
            @Html.X().Label().ID("Label1").Format("Server Time: {0}").Text(DateTime.Now.ToLongTimeString())
    this is the controller:

    using System;
    using System.Web.Mvc;
    using Ext.Net;
    using Ext.Net.MVC;
    using WebApplication1.Models;
    namespace WebApplication1.Controllers
        [DirectController(AreaName = "Events")]
        public class ExtNetController : Controller
            public ActionResult Index()
                ExtNetModel model = new ExtNetModel()
                    Title = "Welcome to Ext.NET",
                    TextAreaEmptyText = ">> Enter a Message Here <<"
                return this.View(model);
            public ActionResult SampleAction(string message)
                X.Msg.Notify(new NotificationConfig
                    Icon = Icon.Accept,
                    Title = "Working",
                    Html = message
                return this.Direct();
            public ActionResult SetTimeStamp()
                var label = this.GetCmp<Label>("Label1");
                label.Text = DateTime.Now.ToLongTimeString();
                return this.Direct();
            public ActionResult LogCompanyInfo(string name, int count)
                string template = string.Concat("<b>{0}</b> has approximately <b>{1}</b> employees.");
                string[] employees = new string[4] { "1-5", "6-25", "26-100", "100+" };
                this.GetCmp<Label>("Label3").Html = string.Format(template, name, employees[count]);
                return this.Direct();
    PS. I noticed I can't make new posts to the Premium side of the forums, we recently purchase Ext.net, I'm pretty sure we still have support.
    Last edited by fabricio.murta; Apr 15, 2019 at 8:55 PM.
  2. #2
    Your forum account was upgraded to a Premium Member and this thread was moved into the Premium forum.

    We are reviewing the thread now and will provide a response soon regarding your DirectMethod question.
    Geoffrey McGill
    Founder & CEO
  3. #3
    Hello, @SoftwareMHC!

    The short answer is: remove AreaName = "Events" from your DirectController attribute, your controller line number 9. Also drop the .Events portion from the client-side code calling direct events.

    The long answer is, the Examples Explorer MVC version uses the MVC Areas concept (kind of old, introduced in MVC 2), and if you look around the MVC Examples Explorer Source, you'll see the area registered for the example you extracted code from is Events. That's why this is needed in the DirectController attribute, or else Ext.NET won't be able to identify direct methods are to be made available to client side in that view.

    I believe your project simply does not use areas.

    There's also this forum post from Vladimir when something identical (I believe) happened: Post #8 in App.direct.undefined.

    Hope this helps!
    Last edited by geoffrey.mcgill; Apr 13, 2019 at 7:58 AM.
  4. #4
    Thank you both :). The solution proposed works!
    Please feel free to close this call.
  5. #5
    Hello @SoftawreMHC!

    Thanks for the feedback, and glad you could sort out the issue!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 4
    Last Post: Mar 08, 2016, 2:52 PM
  2. [CLOSED] Error generating ext.net MVC5 4.6
    By rguardado in forum 3.x Premium Help
    Replies: 1
    Last Post: Dec 03, 2015, 5:58 PM
  3. Replies: 1
    Last Post: Jan 19, 2015, 6:56 PM
  4. ASP.NET MVC5 Ext.Net and SignalR 2.1.0
    By Andrea in forum 2.x Help
    Replies: 4
    Last Post: Oct 16, 2014, 6:04 AM
  5. Paging with DirectMethod in Ext.net version 1.7
    By luiz in forum Feature Requests
    Replies: 3
    Last Post: Nov 27, 2013, 9:10 AM

Posting Permissions