xaf框架中web项目弹出提示框
2012-12-14 14:42
295 查看
//在Controllers文件夹下添加一个TestController.cs文件。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using DevExpress.Xpo; using DevExpress.ExpressApp; using DevExpress.ExpressApp.SystemModule; using DevExpress.ExpressApp.Actions; using DevExpress.Persistent.Base; using Solution34.Module.BusinessObjects; namespace Solution34.Module { [NonPersistent] public class MessageBox { private string message; public string Message { get { return message; } } private MessageBox(string message) { this.message = message; } public static void Show(XafApplication app, ShowViewParameters svp, string message, Action okMethod, Action cancelMethod) { IObjectSpace os = ObjectSpaceInMemory.CreateNew(); MessageBox obj = new MessageBox(message); svp.CreatedView = app.CreateDetailView(os, obj); DialogController dc = app.CreateController<DialogController>(); dc.Accepting += new EventHandler<DialogControllerAcceptingEventArgs>(delegate { if (okMethod != null) okMethod(); }); dc.Cancelling += new EventHandler(delegate { if (cancelMethod != null) cancelMethod(); }); svp.Controllers.Add(dc); svp.Context = TemplateContext.PopupWindow; svp.TargetWindow = TargetWindow.NewModalWindow; svp.NewWindowTarget = NewWindowTarget.Separate; } public static void Show(XafApplication app, string message, Action okMethod, Action cancelMethod) { ShowViewParameters svp = new ShowViewParameters(); Show(app, svp, message, okMethod, cancelMethod); app.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); } } public class MyController:ViewController { public MyController() { SimpleAction action = new SimpleAction(this, "TestMe", PredefinedCategory.View); action.Execute += new SimpleActionExecuteEventHandler(action_Execute); } void action_Execute(object sender, SimpleActionExecuteEventArgs e) { DomainObject obj = ObjectSpace.CreateObject<DomainObject>(); obj.Name = string.Format("sample {0:G}", DateTime.Now); MessageBox.Show(Application, "Confirm test action?", new Action(delegate { obj.Description = "Test OK"; ObjectSpace.CommitChanges(); ObjectSpace.Refresh(); }), new Action(delegate { obj.Description = "Test Cancel"; ObjectSpace.CommitChanges(); ObjectSpace.Refresh(); })); } } }
//BusinessObjects文件夹下添加一个BO.cs文件 using System; using System.Collections.Generic; using System.Linq; using System.Text; using DevExpress.Persistent.BaseImpl; using DevExpress.Xpo; using DevExpress.Persistent.Base; namespace Solution34.Module.BusinessObjects { [NavigationItem] public class DomainObject : BaseObject{ public DomainObject(Session s) : base(s) { } public string Name { get; set; } public string Description { get; set; } } }
运行效果图:
本例子参考=====点击打开链接 http://www.devexpress.com/Support/Center/p/Q427991.aspx
相关文章推荐
- 第三章:利用maven+ssm框架实现maven web项目
- 【C#】对异步请求处理程序IHttpAsyncHandler的理解和分享一个易用性封装 【手记】走近科学之为什么明明实现了IEnumerable<T>的类型却不能调用LINQ扩展方法 【手记】手机网页弹出层后屏蔽底层的滑动响应 【手记】ASP.NET提示“未能创建类型”处理 【Web】一个非常简单的移动web消息框 【手记】解决EXCEL跑SQL遇“查询无法运行或数据库表无法打开...”
- 【web开发】Eclipse中SpringMVC+Mybatis+Maven搭建的项目框架(SMM框架)
- vs.net2003打开Web项目提示物理路径与url路径无法验证问题的解决
- 项目总结SpringMVC+hibernate框架 web.xml 分析(2)
- JavaWeb---框架SpringMvc+Mybatis开发项目第三季(共三季)
- Java web项目框架配置文件
- 打开项目时提示如下错误:Visual Studio .NET 无法创建应用程序 。问题很可能是因为本地 Web 服务器上没有安装所需的组件
- 使用Maven创建Web项目后,jsp引入静态文件提示报错。JSP 报错:javax.servlet.ServletException cannot be resolved to a type
- VS2012 打开项目提示asp.net 4.0尚未在web服务器上注册
- [转]ajax项目提示我缺少Microsoft.Web.Preview.dl和未能加载AjaxControlToolkit程序集解决方法
- python下的web开发框架-Django,创建项目
- 创建Maven项目时提示web.xml is missing and <failOnMissingWebXml> is set to true错误解决方案
- 【持久化框架】SpringMVC+Spring4+Mybatis3集成,开发简单Web项目+源码下载
- 常用前端UI框架快速开发web项目
- VS2010->打开项目时弹出错误提示:未能正确加载......VisualStudio\10.0\ActivityLog.xm
- Python之Web框架Django项目搭建全过程
- VS2013打开项目提示"Asp.net4.5未在web服务器上注册 "
- 【持久化框架】SpringMVC+Spring4+Mybatis3集成,开发简单Web项目+源码下载【转】
- 我的权限系统设计实现MVC4 + WebAPI + EasyUI + Knockout(五)框架及Web项目的组件化