Visit property controls

In addition to the built-in controls and 3rd party controls, we have developed a collection of what we call visit property controls. Visit property controls are controls that render the contents of a property. There are a number of different visit property controls in the system, almost one for each property type:

CheckBoxVisitPropertyControl

A control for rendering the value of a checkbox property. At its most basic it looks like this:

<waf:CheckBoxVisitPropertyControl runat="server" ID="chkProp"
   PropertyName="ArticleBase.ShowInMenu">
</waf:CheckBoxVisitPropertyControl>

 

Without anything else specified, it prints True or False, depending on the value in the property specified in the PropertyName property. Just printing True or False isn’t very useful, but the control also has two templates. One that is used when the checkbox property is False, while the other is used when the checkbox property is True. The templates can contain any html you wish:

<TrueTemplate>
   <b>Yes, of course!!!</b>
</TrueTemplate>

<FalseTemplate>
   <b>Unfortunately not!!!</b>
</FalseTemplate>

 

The templates can also have other visit controls nested inside it:

<waf:CheckBoxVisitPropertyControl runat="server" ID="chkProp"
   PropertyName="CustomArticle.ShowPicture">
   
   <TrueTemplate>
      <b>Yes, of course!!!</b>
      <waf:FileVisitPropertyControl runat="server" ID="imgProp" 
         PropertyName="ArticleBase.IngressImage">
          
         <ImageTemplate>
            <asp:Image runat="server" ID="img" ImageUrl="<%# 
               Container.File.GetUrl(279) %>" />
         </ImageTemplate>
      </waf:FileVisitPropertyControl>
   </TrueTemplate>

   <FalseTemplate>
      <b>Unfortunately not!!!</b>
   </FalseTemplate>
</waf:CheckBoxVisitPropertyControl>

DateTimeVisitPropertyControl

A control for rendering the value of a DateTime property. The simplest version looks like this:

<waf:DateTimeVisitPropertyControl runat="server" ID="dateProp" 
   PropertyName="ContentBase.CreateDate">
</waf:DateTimeVisitPropertyControl>

 

To format the date, you have two properties: DateFormat and DateFormatString. DateFormat is an enum that contains a selection of the most used date presentation options, like ShortDateString, DayName, MonthName, WeekNumber, LongString, ShortTimeString and more. DateFormatString accepts all the string formatting options available in c#.

This prints the DayName in the current culture:

<waf:DateTimeVisitPropertyControl runat="server" ID="dateProp" 
   PropertyName="ContentBase.CreateDate" DateFormat="DayName">
</waf:DateTimeVisitPropertyControl>

 

It is also possible to use several DateTimeVisitPropertyControls on the same property to build the exact DateTime presentation that you need.

The control also has two properties that let you determine if the date should be shown or not: HideIfOlderThan and HideIfNewerThan. They accept a string that can be parsed into a date. An example:

<waf:DateTimeVisitPropertyControl runat="server" ID="dateProp" 
   HideIfOlderThan="2010-11-12" PropertyName="ContentBase.CreateDate">
</waf:DateTimeVisitPropertyControl>

 

The control also have 3 different templates:

EmptyTemplate, HtmlStartTemplate and HtmlEndTemplate

HtmlStartTemplate and HtmlEndTemplate adds html before and after the date is outputted. They are very useful when used in conjunction with the HideIfOlderThan and HideIfNewerThan properties as the templates aren’t rendered if the date shouldn’t be shown.

FileVisitPropertyControl

This is a control that allows you to output content from a file property. 

This control is very template dependent. You can specify the control without any of the templates, but then it will only output a generic link to the file in the property, independent of the file type.

The templates available are:

  • FileLinkTemplate – a template for linking to the file in the file property. Used for videos, sound and images if no video, sound or image template is specified. Used for all other files as well.
  • VideoTemplate – the template used if the file is a video file
  • ImageTemplate – the template used if the file is an image
  • SoundTemplate – the template used if the file is a sound file.
  • EmtptyTemplate – the template used if the property is empty.

 

An example using most of the templates:

<waf:FileVisitPropertyControl runat="server" ID="ingressImageProp"
   PropertyName="ArticleBase.IngressImage">
   
   <ImageTemplate>
      <asp:Image runat="server" ID="img" ImageUrl="<%# 
         Container.File.GetUrl(279) %>" />
   </ImageTemplate>

   <EmptyOrNullTemplate></EmptyOrNullTemplate>
   
   <FileLinkTemplate>
      <a href='<%# Container.File.GetUrl() %>'>Download file</a>
   </FileLinkTemplate>   
   
   <VideoTemplate>
      <asp:Literal runat="server" ID="litV" Text="<%# 
         Container.File.GetVideoPlayer(320,256) %>">
      </asp:Literal>
   </VideoTemplate>      

</waf:FileVisitPropertyControl>

HtmlVisitPropertyControl

This control is used to render the contents of an html property to the page. To render the contents unaltered, you can use the most basic form:

<waf:HtmlVisitPropertyControl ID="htmlProp" 
   PropertyName="ArticleBase.BodyContent" runat="server">
</waf:HtmlVisitPropertyControl>

 

The control has two properties that can help you control what is rendered:

  • AllowedTags – a comma separated list of html tags that you want to be rendered if contained in the html property. All other html tags are filtered out.
  • TagsToFilterOut – If you want to allow most tags, you can specify a comma separated list of tags you want to be removed before the property is rendered.

In addition, the control has two templates: HtmlStartTemplate and HtmlEndTemplate, which let’s you add html to be rendered before and after the contents of the html property.

<waf:HtmlVisitPropertyControl ID="HtmlVisitPropertyControl1" 
   PropertyName="ArticleBase.BodyContent" AllowedTags="p,br,a,img,h2" 
   runat="server">

   <HtmlStartTemplate>
      <b>Before property contents</b>
   </HtmlStartTemplate>

   <HtmlEndTemplate>
      <b>After property contents</b>
   </HtmlEndTemplate>          

</waf:HtmlVisitPropertyControl>

ShortStringVisitPropertyControl

A control to render the contents of a ShortStringProperty. It is normally used like this:

<waf:ShortStringVisitPropertyControl runat="server" ID="nameProp" 
   PropertyName="ArticleBase.Name">      
</waf:ShortStringVisitPropertyControl>

 

The control also has a property called CutOffLength, where the control only renders up to the specified number of characters.

The control also has 3 templates: EmptyTemplate, HtmlStartTemplate and HtmlEndTemplate. The empty template is rendered if the length of the property string is 0. The empty template can contain other  property controls. A common use is when a content class has a LongTitle property that is used in the page, while the name property is used on the menu, where space is often limited. If the LongTitle is empty, you want to use the Name property. It could be used like this:

<waf:ShortStringVisitPropertyControl runat="server" ID="nameProp" 
   PropertyName="ArticleBase.LongTitle">

   <EmptyOrNullTemplate>
      <waf:ShortStringVisitPropertyControl runat="server" ID="nameProp" 
         PropertyName="ArticleBase.Name">
      </waf:ShortStringVisitPropertyControl>
   </EmptyOrNullTemplate>

   <HtmlStartTemplate>
      <h1>
   </HtmlStartTemplate>

   <HtmlEndTemplate>
      </h1>
   </HtmlEndTemplate>

</waf:ShortStringVisitPropertyControl>

IntegerVisitPropertyControl

This control renders the integer value of the property to the page.

LongStringVisitPropertyControl

This control is used to render the LongStringProperty value to the page. To just render the exact contents, the tag looks like this:

<waf:LongStringVisitPropertyControl PropertyName="ArticleBase.Ingress"
   runat="server" ID="ingressProp">
</waf:LongStringVisitPropertyControl>

 

The control has a property called ReplaceLineBreaksWithHtmlLineBreaks, which replaces new lines in the content with <br /> tags, which is useful to make it render as it looked in the textarea when the editor wrote the content.

 

The control also has 3 different templates:

EmptyTemplate, HtmlStartTemplate and HtmlEndTemplate

The templates are rendered when the property is empty, and before and after the contents if it isn’t empty. An example:

<waf:LongStringVisitPropertyControl PropertyName="ArticleBase.Ingress" 
   ReplaceLineBreaksWithHtmlLineBreaks="true" runat="server" ID="ingressProp">

   <EmptyOrNullTemplate>
      Empty!!!!!!!
   </EmptyOrNullTemplate>                 

</waf:LongStringVisitPropertyControl>

RelationVisitPropertyControl

The relation visit property control is the most complex control. It is used to render the related content in the relation property specified. Examples are coming soon.