Mar 31, 2021, 2:59 PM
Error: App.direct is undefined
I followed CLI tutorial, created two template projects Ext.Net MVC and Ext.Net Razor Pages.
Both apps work fine.
However I cannot modify button in DirectEvent View to pass parameters to DirectEvent controller method.
There is no sample in Examples to pass parameter to controller method.
I tried App.direct but it creates an error "App.direct is undefined".
The code for Ext.Net Razor Pages:
And this solution only works for Razor Pages, not for MVC.
Both apps work fine.
However I cannot modify button in DirectEvent View to pass parameters to DirectEvent controller method.
There is no sample in Examples to pass parameter to controller method.
I tried App.direct but it creates an error "App.direct is undefined".
The code for Ext.Net Razor Pages:
@page "{handler?}"
@model ExtDemo1.Pages.DirectEventsModel
@{
ViewData["Title"] = "DirectEvent";
var X = Html.X();
}
<ext-section target="Main">
<ext-container region="Center" scrollable="true" paddingAsString="30 20 30 50">
<content>
<h1>DirectEvent</h1>
<ext-button text="Click Direct" onDirectClick="ButtonClick" />
<ext-button text="Click js alert" onClientClick="alert('client click');" />
<ext-button text="Click Client" onClientClick="clientClick();" />
<ext-label id="lbl" text="ext-label"></ext-label>
</content>
</ext-container>
</ext-section>
<script>
function clientClick() {
//error: App.direct is undefined
App.direct.ButtonClick('client click');
};
</script>
Controller:using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Ext.Net;
using Ext.Net.Core;
using MojeeIO;
namespace ExtDemo1.Pages
{
public class DirectEventsModel : PageModel
{
public void OnGet()
{
}
public IActionResult OnPostButtonClick(string message = "default text")
{
Label lbl = this.GetCmp<Label>("lbl");
lbl.Text = message;
return this.Direct();
}
}
}
The recommendation from GitHub (absent: DirectEvent support #1713) worked after some adjustments:<ext-button text="Click Params">
<directevents>
<click pageHandler="ButtonClick" method="POST" type="Load">
<extraparams>
<ext-add key="message" value="Button Click Params click" />
</extraparams>
</click>
</directevents>
</ext-button>
But calling controller from JavaScript App.direct still does not work :(And this solution only works for Razor Pages, not for MVC.
Last edited by VADIM; Mar 31, 2021 at 5:24 PM.