title: Sharepoint Custom Field
body: <p>I've created a custom field type, I think there are no mistakes, becouse it's so simple, but the field box is not displayed at the form (see pic.)</p>
  
  <p><img src="https://i.stack.imgur.com/GLgHj.jpg" alt="pic"></p>
  
  <p>.ascx file:</p>
  
  <pre><code> &lt;SharePoint:RenderingTemplate ID="MyField" runat="server"&gt;
   &lt;Template&gt;
   &lt;asp:TextBox ID="TextField" MaxLength="255" runat="server" BackColor="Pink"
   Font-Bold="true" BorderStyle="Dotted" BorderColor="DarkBlue" TextMode="MultiLine" /&gt;
   &lt;/Template&gt;
   &lt;/SharePoint:RenderingTemplate&gt;
  </code></pre>
  
  <p>Field Type file:</p>
  
  <pre><code>namespace MyCustomField.CustomField
  {
  class SPFieldMyCustomField : SPFieldMultiLineText
  {
  
      public SPFieldMyCustomField(SPFieldCollection fields, string fieldName) : base(fields, fieldName)
      {
      }
  
      public SPFieldMyCustomField(SPFieldCollection fields, string typeName, string displayName)
          : base(fields, typeName, displayName)
      {
      }
  
      public override BaseFieldControl FieldRenderingControl
      {
          get
          {
              BaseFieldControl control = new MyCustomFieldControl();
              control.FieldName = base.InternalName;
  
              control.ControlMode = SPControlMode.Display;
  
              return control;
          }
      }
  }
  }
  </code></pre>
  
  <p>and Control file:</p>
  
  <pre><code>namespace MyCustomField.CustomField
  {
  internal class MyCustomFieldControl : RichTextField
  {
      protected override void CreateChildControls()
      {
          ControlMode = SPControlMode.Display;
  
          base.CreateChildControls();
      }
  
      protected override void RenderFieldForDisplay(HtmlTextWriter output)
      {
          var html = String.IsNullOrEmpty(Item[Field.InternalName] as string) ? "" : Item[Field.InternalName] as string;
  
          RenderHtmlForDisplay(output, html);
      }
  
      protected override string DefaultTemplateName
      {
          get
          {
              return "MyField"; 
          }
      } 
  }
  }
  </code></pre>
  
  <p>As you can see TextBox isn't displayed.</p>