Error: App.direct is undefined

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    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:
    @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 4:24 PM.

Similar Threads

  1. [CLOSED] Direct Method - App.direct undefined
    By registrator in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 23, 2014, 1:47 PM
  2. App.direct undefined
    By ingbabic in forum 2.x Help
    Replies: 10
    Last Post: Jun 10, 2014, 3:33 PM
  3. App.direct - Response error
    By WojciechK in forum 2.x Help
    Replies: 2
    Last Post: Jun 04, 2014, 7:05 AM
  4. [CLOSED] App.direct is undefined
    By jesperhp in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Dec 04, 2013, 12:53 PM
  5. Error App is undefined.
    By idelacruz in forum 2.x Help
    Replies: 0
    Last Post: Jun 08, 2013, 2:51 PM

Posting Permissions