Page Templates are web forms that provide a very quick way to deliver an application that explores
and edits a database, using a consistent layout. You have seen them in action when using the various BLD Database Explorer applications in this Guided Tour.
Show the BLD Database Explorer Application
These web forms are included with BLD and installed into the [web app]\BLD Templates\PageTemplates folder.
Features of Page Templates:
- They contain all of the controls needed to deliver a BLD driven user interface.
- They acquire the table from ASP.NET URL Routing (such as /Products/Edit.aspx).
- They acquire the data fields from Automatic Scaffolding.
Automatic Scaffolding lets business rules deliver an ordered list of DataFields to show in your DataBound control.
It determines the list of DataFields with guidance from the
DESDA.ScaffoldColumnAttribute, DataBound Control Adapter's ScaffoldSettings property, and other rules.
Since it does not use a predefined list of DataFields, it demands a fixed layout to enclose each DataField that it outputs,
which Page Templates supply.
- They use Pattern Templates to allow extensive customization of the output. (More on this later in the Guided Tour.)
- All tables share a consistent appearance.
You can modify their overall look, changing style sheets, adding controls and modifying
the layout. However, there are limitations to the level of customization as they use Automatic Scaffolding
and Pattern Templates to provide a business logic driven layout.
If you want a different appearance for a table, use Custom Page Templates, which are basically the same web forms,
except located in [web app]\BLD Templates\CustomPages. Custom Page Templates give you full control over output,
including the ability to define the list of DataFields, instead of using Automatic Scaffolding.
In Phase 4, we'll add Custom Page Templates to the BLD Database Explorer application.
Take a tour of the default Page Templates here:
|
<%@ Page Language="C#" MasterPageFile="~/BLD Templates/Content/PageTemplates.master" ValidateRequest="False" %>
<%@ Import Namespace="PeterBlum.DES.DataAnnotations.Descriptors" %>
<%@ Import Namespace="PeterBlum.DES.BLD" %>
<script runat="server">
protected BaseEntityDescriptor fEntityDescriptor;
protected void Page_Init(object sender, EventArgs e)
{
fEntityDescriptor = BaseBLDRouteHandler.GetBLDRouteDetails(Context).EntityDescriptor;
Title = fEntityDescriptor.GetLocalizedDisplayName();
if (fEntityDescriptor.IsReadOnly)
{
RecordsList.AutoGenerateButtons = AutoGenerateButtons.None;
}
} </script>
<asp:Content ID="headContent" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<des:BLDPageManager ID="BLDPageManager1" runat="server"
AutoLoadForeignKeys="true" >
<Adapters>
<des:BLDListViewAdapter DataBoundControlID="RecordsList"
ValidationSummaryControlID="ValidationSummary1"
SupportsEditActions="True" SupportsInsertActions="True"
NoRecordsUsesInsertMode="false"
ActionsUseRouting="true" />
</Adapters>
</des:BLDPageManager>
<h2 class="BLDPT_ActionTitle"><%= Title %></h2>
<asp:ScriptManagerProxy runat="server" ID="ScriptManagerProxy1" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="BLDPT_ListHeader">
<des:ValidationSummary ID="ValidationSummary1" runat="server" InAJAXUpdate="True"
HeaderText="List of validation errors" RelatedControlID="AfterValSum" RelatedControl_InvisiblePreservesSpace="false" />
<des:LocalizableLabel ID="AfterValSum" runat="server" ><br/><br/></des:LocalizableLabel>
<des:BLDPatternForFilterFields ID="Filters" runat="server" />
<br/>
</div>
<des:BLDListView ID="RecordsList" runat="server" DataSourceID="RecordsListDataSource"
AutoGenerateButtons="First" >
</des:BLDListView>
<des:BLDWidgetsView ID="BLDWidgets1" runat="server" PageSize="10" PagedControlID="RecordsList"
ContainerTagAttributes-Height="1.6em" >
<Widgets>
<des:PreviousPagerWidget ContainerTagUsage="OpeningTag"
ContainerTagAttributes-Style="float:left;" />
<des:InfoPagerWidget/>
<des:NextPagerWidget ContainerTagUsage="ClosingTag"/>
<des:NewCommandButtonWidget ContainerTagAttributes-Style="float:right;"
ImageUrl="~/BLD Templates/Content/Images/plus.gif" Text="Insert new item"
LinkButtonLayout="ImageOutside" />
</Widgets>
</des:BLDWidgetsView>
<des:EntityDAODataSource ID="RecordsListDataSource" runat="server"
EnableUpdate="false" EnableInsert="false" EnableDelete="true"
EntityTypeFromRouting="true" >
<EntityFilters>
<des:FilterTemplatesEntityFilter ControlID="Filters" />
<des:UIDataFieldsFinderEntityFilter/>
</EntityFilters>
</des:EntityDAODataSource>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
|
In the next topic, you'll learn how to
use BLD without Page Templates.