您的位置:首页 > 移动开发 > WebAPP

WebApplication,在DetailView的Tab中,当跳转页签时即刻保存提交内容的解决方法

2012-09-14 13:13 274 查看
WebApplication,在DetailView的Tab中,当跳转页签时即刻保存提交内容的解决方法如下:

原文:http://www.devexpress.com/Support/Center/p/Q157281.aspx

重写ASPxPageControlActiveTabChanged事件,ObjectSpace进行提交即可,代码类似下面:

[C#]Open in popup window[code]public class CommitOnTabChangeViewController : ViewController
    {
        public CommitOnTabChangeViewController()
        {
            this.TargetViewType = ViewType.DetailView;
        }
        protected override void OnActivated()
        {
            base.OnActivated();
            ((WebLayoutManager)((DetailView)View).LayoutManager).ItemCreated += new EventHandler<ItemCreatedEventArgs>(ViewController1_ItemCreated);
        }
        protected override void OnDeactivating()
        {
            ((WebLayoutManager)((DetailView)View).LayoutManager).ItemCreated -= new EventHandler<ItemCreatedEventArgs>(ViewController1_ItemCreated);
            base.OnDeactivating();
        }
        void ViewController1_ItemCreated(object sender, ItemCreatedEventArgs e)
        {
            TabbedGroupTemplateContainer tabbedGroup = e.TemplateContainer as TabbedGroupTemplateContainer;
            if (tabbedGroup != null)
            {
                ASPxPageControlEx tabControl = tabbedGroup.Controls[0] as ASPxPageControlEx;
                if (tabControl != null)
                {
                    tabControl.ActiveTabChanged += new DevExpress.Web.ASPxTabControl.TabControlEventHandler(tabControl_ActiveTabChanged);
                }
            }
        }
        void tabControl_ActiveTabChanged(object source, DevExpress.Web.ASPxTabControl.TabControlEventArgs e)
        {
            try
            {
                this.ObjectSpace.CommitChanges();
            }
            catch { }
        }
    }

[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: