Binary Field Control

From Sense/Net Wiki
Jump to: navigation, search
  •  
  •  
  •  
  •  
  • 100%
  • 6.0
  • Enterprise
  • Community
  • Planned

Overview

The Binary Field Control is a Field Control that handles Binary Fields and provides an interface to modify binary data of a Content.

Binary Field Control

Details

With Binary Field Control the binary data of a Content can be added/modified. Depending on the configuration of the Field and the Content Type and extension, the control is rendered as a textarea where you can edit the binary manually or as a fileupload control allowing you uploading a new file. By default an upload control is rendered. A textarea is rendered when:

  • the displayed Content is a Content Type,
  • the displayed Content has an extension that is included in the web.config's EditSourceExtensions entry of the <portalSettings> section,
  • otherwise when the IsText property in the underyling Binary Field's Field Setting is set to true.

When a textarea is rendered it can be displayed as a highlighted editor of bigger size using the FullScreenText property.

Supported Field types

Properties

  • FullScreenText: (optional) renders the textarea in full screen for editing, without file upload control.

For a complete list of common Field Control properties see common Field Control properties.

Templates

Binary field control renders the name of the assigned file as a hyperlink in Browse mode. In Edit mode a fileupload control or a textarea control is rendered.

Browse view template

<%@  Language="C#" %>
<%@ Import Namespace="SenseNet.Portal.UI.Controls" %>
<a href='<%# ((Binary)Container).Field.Content.Path %>'><%# ((Binary)Container).Field.Content.DisplayName %></a>

Edit view template

<%@  Language="C#" %>
<asp:TextBox ID="BinaryTextBox" runat="server" TextMode="MultiLine" CssClass="sn-ctrl sn-ctrl-textarea" Rows="50" Columns="100" />
<asp:FileUpload CssClass="sn-ctrl sn-ctrl-upload" ID="FileUploader" runat="server" Visible="false" />

Example/Tutorials

Simple example

   <sn:Binary ID="BinaryCtrl" runat="server" FieldName="Data1" />

This next example displays the Field Control for editing in full screen.

   <sn:Binary ID="BinaryCtrl" runat="server" FieldName="Data1" RenderMode="Edit" FullScreenText="true" />

Templated example

   <sn:Binary ID="BinaryCtrl" runat="server" FieldName="Data1">
      <EditTemplate>
         <asp:TextBox ID="InnerControl" runat="server" TextMode="MultiLine"></asp:TextBox>
         <asp:FileUpload ID="FileUploader" runat="server" Visible="false" />
      </EditTemplate>
   </sn:Binary>

Related links

References