-
Notifications
You must be signed in to change notification settings - Fork 41
absent: DirectEvent support #1713
Comments
Some basic DirectEvent functionality is supported now. Here's a few basic scenarios: .cshtml.csusing Ext.Net;
using System;
using System.Threading;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace sandbox.Pages
{
[BindProperties(SupportsGet = true)]
public class HomeModel : PageModel
{
public Button MyButton { get; set; }
public void OnGet()
{
MyButton.Id = "Button1";
MyButton.Text = "Submit";
}
public IActionResult OnPostCustomHandler(Button btn)
{
btn.Text = $"Fresh at " + DateTime.Now.ToLongTimeString();
// Option 1:
//var width = btn.Width.As(
// d => d,
// s => double.TryParse(s, out var d) ? d : 0
//);
// Option 2:
//var width = btn.Width.AsDouble();
// Option 3:
var width = btn.Width.AsDouble(out var suffix);
btn.Width = width + 100;
Thread.Sleep(5000);
// Render a new button
var btn4 = new Button { Id = "Button4", Text = "Dynamically Added Button", RenderTo = "App.Button4_Container" };
this.Render(btn4);
return this.DirectResult();
}
}
} .cshtml@page "{handler?}"
@model HomeModel
@{
Layout = null;
var X = Html.X();
}
<!DOCTYPE html>
<html>
@Html.Raw("<head>\n</head>")
<body>
@*<ext-resources />*@
<h1>Ext.NET HOME component tests</h1>
<div>
<ext-button model="Model.MyButton" />
<ext-button id="Button2" text="[TagHelper] Click me #2">
<directevents>
<click pageHandler="CustomHandler" method="POST" type="Load">
<eventmask showMask="true" msg="Custom Mask..." />
<confirmation confirmRequest="true" cancel="alert('confirmation is canceled');" />
<extraparams>
<parameter name="btn.id" value="App.Button2.id" mode="Raw" />
<parameter name="btn.text" value="App.Button2.getText()" mode="Raw" />
<parameter name="btn.width" value="App.Button2.getWidth()" mode="Raw" />
</extraparams>
</click>
</directevents>
</ext-button>
@(X
.Button()
.Id("Button3")
.Text("[HtmlHelper] Click me #3")
.DirectEvents(de =>
{
de.Click.Url = Url.Page("Home", "CustomHandler");
de.Click.Method = HttpMethod.POST;
de.Click.Type = DirectEventType.Load;
de.Click.EventMask.ShowMask = true;
de.Click.EventMask.Msg = "Custom Mask...";
de.Click.Confirmation.ConfirmRequest = true;
de.Click.Confirmation.Cancel = "alert('confirmation is canceled');";
de.Click.ExtraParams.Add("btn.id", "App.Button3.id", ParameterMode.Raw);
de.Click.ExtraParams.Add("btn.text", "App.Button3.getText()", ParameterMode.Raw);
de.Click.ExtraParams.Add("btn.width", "App.Button3.getWidth()", ParameterMode.Raw);
})
)
<div id="App.Button4_Container"></div>
</div>
</body>
</html> |
I couldn't work this out in this attempt to port the Colorpicker > Basic > Overview WebForms example: PageModel: colorpicker/basic/overview/index.cshtml.cs#L21-L26 Page markup: colorpicker/basic/overview/index.cshtml#L23-L33 The approaches I tried all resulted in 400 (bad request) page error on request. |
The second instance of ColorPicker has been fixed. The Postback scenario is not really applicable to ASP.NET Core MVC / Razor pages. The first issue was Razor handler methods must be public. Another issue preventing Ajax requests to come through was CSRF token validation. It was switched off globally for now: services.AddRazorPages(opts =>
opts.Conventions.ConfigureFilter(new IgnoreAntiforgeryTokenAttribute())
); |
How is the progress of XRender feature , the ability to dynamically create a new control during a DirectEvent. |
Much more DirectEvent support has been added to the We still need to add support for Any issues with |
In Ext.NET's Buttons > Basic > Overview example, second button, the direct event fires against the server-side method
Button_Click()
, using WebForms specific event mechanisms to identify the call.From client-side, a direct request (in the above example) submits the following payload to the same page it loaded:
Which decodes into:
Currently, Ext.NET Core submits:
(not encoded at all).
So currently there's no telling what should be run at server side in the ajax call and direct events does not work, at least as far as Razor Pages + Tag Helpers are concerned.
MVC RazorView probably also needs something implementing means to direct to a given Action.
The text was updated successfully, but these errors were encountered: