How to: Disable a Confirmation Dialog in an ASP.NET Core Blazor Application(如何:在 ASP.NET Core Blazor 应用程序中禁用确认对话框)
In XAF ASP.NET Core Blazor applications, a confirmation dialog appears if you attempt to exit a view without saving your changes. The following Controllers implement this functionality:
在XAFASP.NETCore Blazor应用程序中,如果您尝试退出视图而不保存更改,则会出现一个确认对话框。以下控制器实现此功能:
- ConfirmationDetailViewController in Detail Views.
ConfirmationDetailViewController详细视图。 - ConfirmationListViewController in List Views.
列表视图中的ConfirmationListViewController。
This topic demonstrates how to disable the confirmation dialog in a Detail View.
本主题演示如何在详细信息视图中禁用确认对话框。
Step-by-Step Instructions(分步说明)
1.In the YourSolutionName.Blazor.Server\Controllers folder, create a new Controller and name it BlazorSuppressConfirmationsController.
在YourSolutionName. Blazor.Server\Controller文件夹中,创建一个新的Controller并将其命名为BlazorSuppressConfirmationsController。
2.Replace the auto-generated code with the following code snippet:
将自动生成的代码替换为以下代码片段:
C#
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor.SystemModule;
namespace MainDemo.Module.Blazor.Controllers {
public class BlazorSuppressConfirmationsController : ViewController {
protected override void OnActivated() {
base.OnActivated();
var confirmationDetailViewController = Frame.GetController<ConfirmationDetailViewController>();
if (confirmationDetailViewController != null) {
confirmationDetailViewController.Active["DeactivateInCode"] = false;
}
}
}
}
Build the project and run the application. Open a Detail View and change a property value. When you close the view, XAF does not save the changes and the confirmation dialog does not appear.
构建项目并运行应用程序。打开详细信息视图并更改属性值。关闭视图时,XAF不会保存更改,也不会出现确认对话框。
Tip
The ConfirmationDetailViewController and ConfirmationListViewController are active for non-persistent objects only if the AutoSetModifiedOnObjectChange property is set to true.
仅当AutoSetModifiedOnObjectChange属性设置为true时,ConfirmationDetailViewController和ConfirmationListViewController才对非持久性对象有效。