The Details view content place holder is found in ProjectModule.aspx that we created earlier
The DetailsView renders a simple item. The example code given below renders the details of a specific project. This view creates a dependent view “FullListItem_Project”.
CopyC#
<asp:Content ID="Content2" ContentPlaceHolderID="CurrentItemView" runat="server"> <% var itemModel = Model as Cartella.Classes.IProject; if (itemModel != null) { var boxData = new ViewDataDictionary(); ////////////////////////////////////////////////////////// /// Render document item full details box ////////////////////////////////////////////////////////// ButtonWrapper[] buttons = (Model.CanCreate) ? new ButtonWrapper[] { new ButtonWrapper() { Label = "Create New Project", Url = Url.Action("Create", "FolioItem", new { itemType = "Cartella.Classes.Project" }) } } : null; boxData.Add(new KeyValuePair<string, object>("Title", itemModel.CurrentItem.Item.Name)); boxData.Add(new KeyValuePair<string, object>("partialViewName", "FullListItem_")); ViewInformation blogItemBox = new ViewInformation("BoxDisplay", boxData, buttons); ViewInformation blogItem = new ViewInformation("FullListItem_Project", itemModel.CurrentItem); blogItemBox.AddChildView(blogItem); Html.CartellaRenderNested(blogItemBox); ////////////////////////////////////////////////////////// /// Render document item full details box end ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// /// Render comments box ////////////////////////////////////////////////////////// Html.CartellaRenderPartial("Comments/Comments", itemModel); ////////////////////////////////////////////////////////// /// Render comments box end ////////////////////////////////////////////////////////// } %> </asp:Content>
Caution |
---|
The code above calls the "FullListItem_Project" view. The next step will assume that you are using the code above. |
Create the FullListItem_Project View
In the "Shared" folder, create a new view called "FullListItem_Project.ascx".
Fill in the newly created view:
CopyC#
<%@ Import Namespace="Cartella.Models" %> <%@ Import Namespace="Cartella.Models.EditForm" %> <%@ Import Namespace="Cartella.Classes" %> <%@ Import Namespace="Cartella.Interfaces" %> <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Cartella.Models.FolioItemWrapper>" %> <% var model = ViewData.Model; var item = model.FolioItem as Cartella.Classes.IProject; if (item != null) { %> <div class="blogPostTitle"> <% Html.CartellaRenderPartial("FolioItem_Buttons", model); %> <div class="clearBoth"> </div> </div> <p class="blogPostDate"> <%= item.CreationDate.Value.ToShortDateString() %> posted by <% = (item.CreationUser != null) ? item.CreationUser.FirstName + " " + item.CreationUser.LastName : "Anonomous"%></p> <div class="copy"> <%= item.Description%> <div class="clearBoth"></div> </div> <div class="copy"> <p>Start Date: <%= item.StartDate.ToString("MM/dd/yyyy")%></p> <p>Projected End Date: <%= item.ProjectedEndDate.ToString("MM/dd/yyyy")%></p> <% if (item.ActualEndDate > DateTime.MinValue) { %> <p>Completion Date: <%= item.ActualEndDate.ToString("MM/dd/yyyy")%></p> <% } %> </div> <!-- document links and versions --> <% AssetHistoryLinks history = new AssetHistoryLinks(item.Asset); Html.CartellaRenderPartial("AssetVersion/AssetVersions", history, new ViewDataDictionary() { { "Editable", item.Editable } }); %> <p class="copy"> Posted in: <% foreach (ICategory category in item.Categories.Values) { Response.Write(Html.ActionLink(category.Name, "Index", "FolioModule", new { folioID = item.OwnerFolio.ID, folioModuleLabel = item.OwnerModule.Label, category = category.ID }, null) + " "); } if (item.Categories.Count == 0) { Response.Write("Uncategorized"); } } %> </p>