/// <summary> /// Loads a chapter /// </summary> /// <param name="isDefault">True if called on !Postback which will load the default chapter for the document.</param> protected void LoadChapter(bool isDefault) { IList <ChapterVersion> chapters = DocoManager.GetAllItemsByArticleId(ArticleId); int lowestOrderNumber = DocoManager.GetLowestSequenceNumber(ArticleId); //Load the chapter from the docoID if (chapters.Count > 0) { divEditor.Style.Add("display", "block"); List <ChapterVersion> chapVersions = new List <ChapterVersion>(); if (isDefault) { var chaps = from c in chapters where c.Sequence == lowestOrderNumber select c; chapVersions = chaps.ToList <ChapterVersion>(); } else { var chaps = from c in chapters where c.Id == ChapterId select c; chapVersions = chaps.ToList <ChapterVersion>(); } ChapterVersion chVersion = chapVersions.First(); lblChapterName.Text = chVersion.Name; txtBoxChapterName.Text = chVersion.Name; lblChapterNameEditor.InnerHtml = chVersion.Name; ChapterId = chVersion.Id; ChapterName = chVersion.Name; int chapNumb = (chVersion.Sequence + 1); if (!string.IsNullOrEmpty(contentMode) && contentMode.Equals("pub")) { //set the content in the editor or literal depending on the mode. if (chapVersions.Count <ChapterVersion>() > 0) { DisplayContent(chVersion.Content, chapNumb, IsNumbChaps); } else { DisplayContent("", chapNumb, IsNumbChaps); } //Bind drafts if any found for this chapter. //divDraftsList.InnerHtml = BindDrafts(ChapterId); } else { IList <Draft> drafts = DocoManager.GetDraftsByChapterId(ChapterId); if (drafts.Count > 0) { Draft draft = drafts.FirstOrDefault <Draft>(); if (draft != null) { DisplayContent(draft.Content, chapNumb, IsNumbChaps); } else { DisplayContent("", chapNumb, IsNumbChaps); } } else //load published version by default { if (chapVersions.Count <ChapterVersion>() > 0) { DisplayContent(chVersion.Content, chapNumb, IsNumbChaps); } else { DisplayContent("", chapNumb, IsNumbChaps); } } } } else { previewDiv.Style.Add("display", "none"); divEditor.Style.Add("display", "none"); } }