How can I customize rendering of a custom field type in SharePoint using server side code?

I searched on the net but I am getting examples with csr technology i.e. JSLink. I want to know how I can do it in another way.

I want my field to have a default value or placeholder when displayed in new form for a list or library.

1 Answer 1


Setting default values for custom field types is only possible in changing the implementation on server side.

Check out this nice MSDN walkthrough regarding the implementation of custom field types.

The sample explains also how to set a default value.

protected override void CreateChildControls()
    if (this.Field != null)
        // Make sure inherited child controls are completely rendered.

        // Associate child controls in the .ascx file with the 
        // fields allocated by this control.
        this.ISBNPrefix = (Label)TemplateContainer.FindControl("ISBNPrefix");
        this.textBox = (TextBox)TemplateContainer.FindControl("TextField");
        this.ISBNValueForDisplay = (Label)TemplateContainer.FindControl("ISBNValueForDisplay");

        if (this.ControlMode != SPControlMode.Display)
            if (!this.Page.IsPostBack)
                if (this.ControlMode == SPControlMode.New)
                    // setting default value here!
                    textBox.Text = "0-000-00000-0";
            // Assign current value from database to the label control
            ISBNValueForDisplay.Text = (String)this.ItemFieldValue;
  • Can you tell me that how can i add this as a watermark ? means the text should disappear as soon as i click on the textbox Apr 28, 2015 at 10:06
  • Please mark as answer when this was helpful ;) What do you mean with watermark? When the user clicks on the field the text should disappear? I don't understand your requirement. Apr 28, 2015 at 10:07
  • for example if you this comment box of stack exchange, when you start typing the default text in it gets disappeared. i want this same thing for my custom field type. Apr 28, 2015 at 10:12
  • Ahh OK I understand. This is only possible in conjunction with CSR (Client Side Rendering) in JSLink. When the field is empty (has no value) then just inject some text with JavaScript. When the field is in edit mode, then keep it empty. I didn't implement such a thing but I think it should work in this way. Apr 28, 2015 at 11:36
  • how can i add that using CSR ? Apr 28, 2015 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.