syncfusion-aspnetcore-popups
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing Dialog — ASP.NET Core
Dialog组件实现——ASP.NET Core
This skill documents how to implement, configure, and customize the Syncfusion Dialog in ASP.NET Core applications using the Tag Helper API. It covers setup, modality, positioning, animations, templates, events, accessibility, and styling.
<ejs-dialog>本技能文档介绍如何在ASP.NET Core应用中使用 Tag Helper API实现、配置和自定义Syncfusion Dialog组件,内容包括设置、模态性、定位、动画、模板、事件、无障碍访问及样式设置。
<ejs-dialog>Quick Links
快速链接
- API Reference
- Getting Started
- Basic Features
- Positioning & Sizing
- Animations & Transitions
- Templates
- Accessibility & Localization
- Events & Interactions
- Styling & Themes
- API参考
- 入门指南
- 基础功能
- 定位与尺寸
- 动画与过渡
- 模板
- 无障碍访问与本地化
- 事件与交互
- 样式与主题
Quick Start (Tag Helper)
快速入门(Tag Helper)
In your Razor view:
csharp
@using Syncfusion.EJ2
<ejs-dialog id="dialog" header="Welcome" isModal="true" width="500px">
<e-content-template>
<p>This is a basic dialog with default settings.</p>
</e-content-template>
</ejs-dialog>
<script>
window.onload = function () {
document.getElementById('openBtn').onclick = function () {
document.getElementById('dialog').ej2_instances[0].show();
};
};
</script>Ensure you include the script manager and styles in your layout ():
_Layout.cshtmlcsharp
<!-- In <head> -->
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/{{ site.ej2version }}/fluent.css" />
<!-- At end of <body> -->
<script src="https://cdn.syncfusion.com/ej2/{{ site.ej2version }}/dist/ej2.min.js"></script>
<ejs-scripts></ejs-scripts>在Razor视图中:
csharp
@using Syncfusion.EJ2
<ejs-dialog id="dialog" header="Welcome" isModal="true" width="500px">
<e-content-template>
<p>This is a basic dialog with default settings.</p>
</e-content-template>
</ejs-dialog>
<script>
window.onload = function () {
document.getElementById('openBtn').onclick = function () {
document.getElementById('dialog').ej2_instances[0].show();
};
};
</script>确保在布局文件()中引入脚本管理器和样式:
_Layout.cshtmlcsharp
<!-- In <head> -->
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/{{ site.ej2version }}/fluent.css" />
<!-- At end of <body> -->
<script src="https://cdn.syncfusion.com/ej2/{{ site.ej2version }}/dist/ej2.min.js"></script>
<ejs-scripts></ejs-scripts>Common Patterns
常见模式
Modal Confirmation Dialog
模态确认对话框
csharp
<ejs-dialog id="confirmDialog" header="Confirm Action" isModal="true" width="400px">
<e-dialog-buttons>
<e-dialog-dialogbutton content="Yes" isPrimary="true" click="confirmAction"></e-dialog-dialogbutton>
<e-dialog-dialogbutton content="No" click="closeDialog"></e-dialog-dialogbutton>
</e-dialog-buttons>
<e-content-template>
<p>Are you sure you want to proceed?</p>
</e-content-template>
</ejs-dialog>csharp
<ejs-dialog id="confirmDialog" header="Confirm Action" isModal="true" width="400px">
<e-dialog-buttons>
<e-dialog-dialogbutton content="Yes" isPrimary="true" click="confirmAction"></e-dialog-dialogbutton>
<e-dialog-dialogbutton content="No" click="closeDialog"></e-dialog-dialogbutton>
</e-dialog-buttons>
<e-content-template>
<p>Are you sure you want to proceed?</p>
</e-content-template>
</ejs-dialog>Draggable Dialog with Header
可拖动带标题的对话框
csharp
<ejs-dialog id="draggableDialog"
header="Drag Me"
allowDragging="true"
width="500px"
showCloseIcon="true">
<e-content-template>
<p>Grab the header to drag this dialog.</p>
</e-content-template>
</ejs-dialog>csharp
<ejs-dialog id="draggableDialog"
header="Drag Me"
allowDragging="true"
width="500px"
showCloseIcon="true">
<e-content-template>
<p>Grab the header to drag this dialog.</p>
</e-content-template>
</ejs-dialog>Centered Dialog
居中对话框
csharp
<ejs-dialog id="centeredDialog"
header="Centered Position"
width="500px">
<e-dialog-position x="center" y="center"></e-dialog-position>
<e-content-template>
<p>This dialog is centered on the page.</p>
</e-content-template>
</ejs-dialog>csharp
<ejs-dialog id="centeredDialog"
header="Centered Position"
width="500px">
<e-dialog-position x="center" y="center"></e-dialog-position>
<e-content-template>
<p>This dialog is centered on the page.</p>
</e-content-template>
</ejs-dialog>Key Properties
关键属性
| Tag Helper Attribute | Type | Purpose | Example |
|---|---|---|---|
| string | Dialog title bar text | |
| bool | Shows overlay behind dialog | |
| string | Dialog width (px, %) | |
| string | Dialog height (px, %) | |
| string | Minimum dialog height | |
| bool | Enable drag to reposition | |
| bool | Enable end-user resizing | |
| bool | Display close (X) button | |
| bool | Close on Escape key | |
| bool | Initial visibility | |
| string | Target container selector | |
| string | Custom CSS class(es) | |
| bool | Right-to-left rendering | |
| bool | Persist state on reload | |
| double | Z-order stacking level | |
| DialogPositionData | X/Y positioning | |
| DialogAnimationSettings | Open/close animation | |
| string | Custom footer HTML string | |
Removed invalid APIs:(useis-hidden),visible="false"/position-xflat attributes (useposition-y),<e-dialog-position>(useallow-resizing),enable-resize,max-height,max-width(not supported).min-width
| Tag Helper 属性 | 类型 | 用途 | 示例 |
|---|---|---|---|
| string | 对话框标题栏文本 | |
| bool | 在对话框后方显示遮罩层 | |
| string | 对话框宽度(px、%) | |
| string | 对话框高度(px、%) | |
| string | 对话框最小高度 | |
| bool | 启用拖动重定位 | |
| bool | 允许用户调整尺寸 | |
| bool | 显示关闭(X)按钮 | |
| bool | 按下Esc键关闭对话框 | |
| bool | 初始可见性 | |
| string | 目标容器选择器 | |
| string | 自定义CSS类 | |
| bool | 从右到左渲染 | |
| bool | 重载时保留状态 | |
| double | Z轴堆叠层级 | |
| DialogPositionData | X/Y定位 | |
| DialogAnimationSettings | 打开/关闭动画 | |
| string | 自定义页脚HTML字符串 | |
已移除的无效API:(改用is-hidden)、visible="false"/position-x扁平属性(改用position-y)、<e-dialog-position>(改用allow-resizing)、enable-resize、max-height、max-width(暂不支持)。min-width
Next Steps
下一步操作
Read for full installation steps, NuGet package setup, and configuration details.
getting-started.md阅读获取完整的安装步骤、NuGet包设置及配置详情。
getting-started.md