コード例 #1
0
ファイル: FormPortlet.cs プロジェクト: pchaozhong/FlexNet
        //-- Methods -----------------------------------------------------

        private void CreateNewFormItem()
        {
            if (CurrentForm == null)
            {
                return;
            }

            var act         = CurrentForm.GetAllowedChildTypes();
            var allowedType = act.FirstOrDefault(ct => ct.IsInstaceOfOrDerivedFrom("FormItem"));
            var typeName    = allowedType == null ? "FormItem" : allowedType.Name;

            _cFormItem = SNC.Content.CreateNew(typeName, CurrentForm, null);

            try
            {
                if (string.IsNullOrEmpty(ContentViewPath))
                {
                    _cvFormItem = ContentView.Create(_cFormItem, this.Page, ViewMode.New);
                }
                else
                {
                    _cvFormItem = ContentView.Create(_cFormItem, this.Page, ViewMode.New, ContentViewPath);
                }

                _cvFormItem.ID          = "cvNewFormItem";
                _cvFormItem.Init       += new EventHandler(_cvFormItem_Init);
                _cvFormItem.UserAction += new EventHandler <UserActionEventArgs>(_cvFormItem_UserAction);

                this.Controls.Add(_cvFormItem);
            }
            catch (Exception ex)         //logged
            {
                Logger.WriteException(ex);
                this.Controls.Clear();
                this.Controls.Add(new LiteralControl("ContentView error: " + ex.Message));
            }
        }