ASP.NET
在ASP.NET XAF应用程序中,使用ASPxPopupControl显示弹出对话框窗口。 如果设置中没有限制,最终用户可以拖动右下角的大小手柄来调整弹出窗口的大小,还可以在代码中自定义初始大小,主窗口的大小等于浏览器窗口大小。本主题介绍如何以编程方式调整大小和自定义弹出窗口,具体取决于显示的视图。
设置弹出窗口的默认大小和样式
如果要使用新的Web UI为ASP.NET应用程序中的所有弹出窗口应用统一样式,建议使用以下XafPopupWindowControl的静态属性。- XafPopupWindowControl.DefaultWidth
- XafPopupWindowControl.DefaultHeight
- XafPopupWindowControl.PopupTemplateType
- XafPopupWindowControl.ShowPopupMode
using DevExpress.ExpressApp.Web.Controls; using System.Web.UI.WebControls; //... protected void Application_Start(object sender, EventArgs e) { XafPopupWindowControl.DefaultHeight = Unit.Percentage(50); XafPopupWindowControl.DefaultWidth = Unit.Percentage(60); XafPopupWindowControl.PopupTemplateType = PopupTemplateType.FindDialog; XafPopupWindowControl.ShowPopupMode = ShowPopupMode.Centered; //... }如果使用经典Web UI在ASP.NET应用程序中自定义弹出窗口,则可以使用IModelPopupWindowOptionsWeb.WindowHeight和IModelPopupWindowOptionsWeb.WindowWidth属性在模型编辑器中设置默认高度和宽度。

处理CustomizePopupWindowSize事件
using System.Web.UI.WebControls; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Web; //... public class CustomizePopupSizeController : WindowController { public CustomizePopupSizeController() { this.TargetWindowType = WindowType.Main; } protected override void OnActivated() { base.OnActivated(); ((WebApplication)Application).PopupWindowManager.PopupShowing += PopupWindowManager_PopupShowing; } private void PopupWindowManager_PopupShowing(object sender, PopupShowingEventArgs e) { e.PopupControl.CustomizePopupWindowSize += XafPopupWindowControl_CustomizePopupWindowSize; } private void XafPopupWindowControl_CustomizePopupWindowSize(object sender, DevExpress.ExpressApp.Web.Controls.CustomizePopupWindowSizeEventArgs e) { e.Width = new Unit(600); e.Height = new Unit(400); e.Handled = true; } }此代码将所有对话框窗口的初始大小设置为600x400。 阅读以下部分以了解如何动态设置大小。
展开评估弹出窗口中显示的视图并相应地设置大小
要访问弹出窗口中显示的视图,请使用ShowViewSource.SourceView属性。 例如,要调整DemoTask类型的弹出窗口的大小,请使用以下代码。using System.Web.UI.WebControls; //... private void XafPopupWindowControl_CustomizePopupWindowSize(object sender, DevExpress.ExpressApp.Web.Controls.CustomizePopupWindowSizeEventArgs e) { if (e.ShowViewSource.SourceView.ObjectTypeInfo.Type == typeof(DemoTask)) { e.Width = new Unit(600); e.Height = new Unit(400); e.Handled = true; } }您还可以使用BaseXafPage.View属性访问父视图(弹出窗口后面显示的视图)。 如果需要自定义从特定Frame调用的弹出窗口并在其中显示特定类型的对象,请使用CustomizePopupWindowSizeEventArgs.PopupFrame和CustomizePopupWindowSizeEventArgs.SourceFrame属性。 以下示例说明如何使用Contact对象从窗口调用DemoTask对象来自定义弹出窗口。
using DevExpress.ExpressApp.Web.Controls; using System.Web.UI.WebControls; //... private void XafPopupWindowControl_CustomizePopupWindowSize(object sender, CustomizePopupWindowSizeEventArgs e) { if ((e.PopupFrame.View.ObjectTypeInfo.Type == typeof(DemoTask)) && (e.SourceFrame.View.ObjectTypeInfo.Type == typeof(Contact))) { e.Width = new Unit(600); e.Height = new Unit(400); e.Handled = true; } }如果弹出视图是引用属性编辑器(ASPxLookupPropertyEditor或ASPxObjectPropertyEditor)的嵌入式部分,则可能需要确定哪个查找是调用弹出窗口的源。 以下代码段演示了如何确定源查找窗口。 在此示例中,Data属性提供对编辑器操作引用的访问。
using DevExpress.ExpressApp.Web.Controls; using DevExpress.ExpressApp.Web.Editors.ASPx; //... private void XafPopupWindowControl_CustomizePopupWindowSize(object sender, CustomizePopupWindowSizeEventArgs e) { if(e.ShowViewSource != null && e.ShowViewSource.SourceAction != null && e.ShowViewSource.SourceAction.Data.ContainsKey(ASPxObjectPropertyEditorBase.EditorActionRelationKey)) { ASPxLookupPropertyEditor lookupPropertyEditor = e.ShowViewSource.SourceAction.Data[ASPxObjectPropertyEditorBase.EditorActionRelationKey] as ASPxLookupPropertyEditor; } }
买 DevExpress Universal Subscription 免费赠 万元汉化资源包1套!
限量15套!先到先得,送完即止!立即抢购>>
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/1220.html
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/1220.html