Name Field Control

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

Overview

The Name Field Control is a Field Control that provides an interface to display/modify the Name of Content. The Name is a fragment of the Content Path, it cannot contain special characters and is stored in a ShortText Field defined on GenericContent Content Type.

DisplayName and Name Field Controls

Details

Special characters are not allowed for a Name. Changing the Name of a Content may affect the portal's standard flow of operation, as the Path act as a permalink to the Content and changing it may cause broken links in the portal. The Content also have a DisplayName field which holds the legible (human-readable) name of the Content. The Name and DisplayName relate to each other in many cases. For some Content for example the DisplayName also determines the Name and for other Content the latter determines the former one. Please refer to Content naming to read detailed information on this topic.

Supported Field types

Properties

  • NeverOverrideDisplayName: (optional) When set to "true", the Field Control will not set the Content's DisplayName even if the DisplayName Field Control is not present in the Content View. Default is false.
  • AlwaysEditable: (optional) When set to "true", the control is rendered as editable (and the user does not have to explicitely click on the edit button to change the Field Control's value. This option is used by the Rename Portlet when only the Name Field Control is rendered. Default is false.

Templates

The Name Field Control is a composite Field Control that renders a single TextBox for the name and one for the extension with some special attributes, and a hidden TextBox to hold the information of whether a DisplayName Field Control is also rendered into the same Content View. A label is rendered to show the autogenerated name. In Browse mode simply the value of the Field is rendered.

Browse view template

<%@  Language="C#" %>
<%# DataBinder.Eval(Container, "Data") %>

Edit view template

<%@  Language="C#" %>
<asp:TextBox ID="InnerShortText" CssClass="sn-ctrl sn-ctrl-text sn-urlname-control" runat="server" style="display:none;"></asp:TextBox>
<asp:TextBox ID="ExtensionText" runat="server" CssClass="sn-ctrl sn-ctrl-text sn-urlname-extensionlabel" style="width: 50px; display:none;"></asp:TextBox>
<asp:Label ID="LabelControl" runat="server" CssClass="sn-urlname-label"></asp:Label>
<asp:ImageButton ID="EditButtonControl" runat="server" ImageUrl="/Root/Global/images/icons/16/edit.png" />
<asp:ImageButton ID="CancelButtonControl" runat="server" ImageUrl="/Root/Global/images/icons/16/delete.png" style="display:none;"/>
<asp:TextBox ID="DisplayNameAvailableControl" runat="server" style="display:none;"></asp:TextBox>

Example/Tutorials

Simple example

   <sn:Name ID="DisplayName1" runat="server" FieldName="Data1" />


Templated example

   <sn:Name ID="Name1" runat="server" FieldName="Data1">
      <EditTemplate>
         <asp:TextBox ID="InnerShortText" CssClass="sn-ctrl sn-ctrl-text sn-urlname-control" runat="server" style="display:none;"></asp:TextBox>
         <asp:TextBox ID="ExtensionText" runat="server" CssClass="sn-ctrl sn-ctrl-text sn-urlname-extensionlabel" style="width: 50px; display:none;"></asp:TextBox>
         <asp:Label ID="LabelControl" runat="server" CssClass="sn-urlname-label"></asp:Label>
         <asp:ImageButton ID="EditButtonControl" runat="server" ImageUrl="/Root/Global/images/icons/16/edit.png" />
         <asp:ImageButton ID="CancelButtonControl" runat="server" ImageUrl="/Root/Global/images/icons/16/delete.png" style="display:none;"/>
         <asp:TextBox ID="DisplayNameAvailableControl" runat="server" style="display:none;"></asp:TextBox>
      </EditTemplate>
   </sn:LongText>

Related links

References