Apr 12, 2019, 9:50 PM
[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:
https://mvc.ext.net/#/Events/DirectMethod/
then when I go into the View and click on the button, I notice a JS exception:
this is the view:
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:
https://mvc.ext.net/#/Events/DirectMethod/
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
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>
<html>
<head>
<title>Ext.NET MVC Sample</title>
</head>
<body>
@(Html.X().ResourceManager())
@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())
}
</body>
</html>
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
}).Show();
return this.Direct();
}
[DirectMethod]
public ActionResult SetTimeStamp()
{
var label = this.GetCmp<Label>("Label1");
label.Text = DateTime.Now.ToLongTimeString();
label.Element.Highlight();
return this.Direct();
}
[DirectMethod]
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 7:55 PM.