Exemplo n.º 1
0
        protected override void Initialize()
        {
            ReturnHyperLink.NavigateUrl = String.Format("TemplateGroupDetail.aspx?file={0}", TemplateGroupFileName);
            //通过模板别名和是否详细模板读取
            if (FileAlias != null && IsDetail != null && TemplateGroupFileName != null)
            {
                //读取模板别名
                TemplateGroup tg = TemplateHelper.GetTemplateGroup(TemplateGroupFileName);
                foreach (TemplateGroup.Item it in tg.Items)
                {
                    if (it.Alias == FileAlias && it.IsDetailTemplate.ToString() == IsDetail)
                    {
                        DeleteItemAliasTextBox.Text = AliasTextBox.Text = AliasWordsTextBox.Text = it.Alias;
                        We7Helper.SetDropdownList(IsDetailTemplateDropDownList, it.IsDetailTemplate ? Boolean.TrueString : Boolean.FalseString);
                        DeleteItemIsDetailTextBox.Text = it.IsDetailTemplate ? Boolean.TrueString : Boolean.FalseString;
                        FileName           = it.Template;
                        AliasPanel.Visible = true;
                    }
                }
            }
            //通过模板文件名读取
            if (AscxFile != null && TemplateGroupFileName != null)
            {
                FileName           = AscxFile;
                AliasPanel.Visible = false;
            }
            if (FileNameAlias != null && FileNameAlias != "")
            {
                FileName = FileNameAlias;
            }
            if (FileName != null && FileName != "" && TemplateGroupFileName != null)
            {
                Template t = TemplateHelper.GetTemplate(FileName + ".xml", Path.GetFileNameWithoutExtension(TemplateGroupFileName));
                if (t != null)
                {
                    NameTextBox.Text         = t.Name;
                    DescriptionTextBox.Text  = t.Description;
                    CreatedLabel.Text        = t.Created.ToString();
                    FileNameTextBox.Text     = t.FileName;
                    FileNameTextBox.ReadOnly = true;
                    We7Helper.SetDropdownList(TypeList, t.IsSubTemplateText);
                    CodeDropDownList.SelectedValue = t.IsCode ? Boolean.TrueString : Boolean.FalseString;
                    if (t.IsSubTemplate)
                    {
                        ComposeHyperLink.NavigateUrl = String.Format("Compose.aspx?file={0}&folder={1}&&templateSub=sub", t.FileName, Path.GetFileNameWithoutExtension(TemplateGroupFileName));
                        AliasPanel.Visible           = false;
                    }
                    else
                    {
                        ComposeHyperLink.NavigateUrl = String.Format("Compose.aspx?file={0}&folder={1}", t.FileName, Path.GetFileNameWithoutExtension(TemplateGroupFileName));
                        AliasPanel.Visible           = true;
                    }
                    TitleLabel.Text   = "编辑模板文件";
                    SummaryLabel.Text = String.Format("修改模板文件 {0}", t.FileName);
                    //TypeList.Enabled = false;
                    ComposeHyperLink.Enabled = true;
                }
            }
            else if (FileName == null || FileName == "" && TemplateGroupFileName != null)
            {
                DateTime now = DateTime.Now;

                ComposeHyperLink.NavigateUrl = String.Format("Compose.aspx?file={0}&folder={1}", FileAlias, Path.GetFileNameWithoutExtension(TemplateGroupFileName));
                ComposeHyperLink.Enabled     = true;
            }
            else
            {
                Messages.ShowError("Url信息不完整。");
                ComposeHyperLink.NavigateUrl = SaveHyperLink.NavigateUrl = "";
            }
        }