I'm trying to understand the new way to handle direct events.
I'm back from webforms and it is all brand new for me, so I'm sorry if I don't have the right approach to this system.
I'm asking you if this one is the correct way to work on it.


In order to read ExtraParams I created a Model class (IndexLoginPageModel) and I added it in the button click sub.


Index.cshtml

@page  "{handler?}"
@model BBros.OggunWeb.Pages.IndexModel
@{ Layout = null; }

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Ext.NET web application</title>
</head>
<body>
    <ext-container model="Model.Sample" />
</body>
</html>
Index.cshtml.cs

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

using Ext.Net;
using Ext.Net.Core;
using System;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using System.Diagnostics;
using System.Text.Json;
using Newtonsoft.Json.Linq;

namespace BBros.OggunWeb.Pages
{
    [DirectModel]
    public class IndexModel : PageModel
    {
        public Container Sample { get; set; }
        public void OnGet()
        {
            var vp = new Viewport()
            {
                Layout = LayoutType.Border
            };

            var head = new Panel()
            {
                Closable = false,
                Region = RegionType.North,
                Height = 130,
                Border = false,
                Header = false,
                BodyStyle = "background-color: transparent",
                Anchor = "100%"
            };

            head.Items.Add(new TextField
            {
                Id = "UserNameTextbox",
                FieldLabel = "Nome utente"
            });

            head.Items.Add(new TextField
            {
                Id = "PasswordTextbox",
                FieldLabel = "Password",
                InputType = InputType.Password.ToString()
            });

            var btn = new Button() { Id = "LoginButton", Text = "Login" };            
            btn.DirectEvents.Click.Method = HttpMethod.POST;
            btn.DirectEvents.Click.ExtraParams.Add(new DirectEventParameter { Name = "m.username", Value = "App.UserNameTextbox.getValue()", Mode = ParameterMode.Raw });
            btn.DirectEvents.Click.ExtraParams.Add(new DirectEventParameter { Name = "m.password", Value = "App.PasswordTextbox.getValue()", Mode = ParameterMode.Raw });
            btn.DirectEvents.Click.Url = "LoginButtonClick";

            head.Items.Add(btn);

            vp.Items.Add(head);

            Sample = new Container()
            {
                Items =
                {
                    vp
                }
            };

        }

        [Direct]
        public IActionResult OnPostLoginButtonClick(IndexLoginPageModel m)
        {
            
            this.X().Toast("Login Button Clicked 👍👍 <br />Username: " + m.Username + "<br />Password: " + m.Password);
            
            return this.Direct();
        }
    }

    public class IndexLoginPageModel
    {
        public string Username { get; set; }
        public string Password { get; set; }
    }
}
This code is working, but I would like not to create a model for any set of ExtraParams I need.
I tried to replace the model data type to "Object", "JToken", "JObject" unsuccessfully.

I would like to deserialize it to something I can handle like the ExtraParams in WebForms approach, using the string key of an array, or any other comfortable way.

Which is the desinged way?

Thank you!