SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to format a Sharepoint:FormField in a view/edit form and used FormattedString, but it doesn´t work. I do this because I would like to display a number without comma separator.

<SharePoint:FormattedString FormatText="Text in field: {0}">
<SharePoint:FormField Grid.Column="0" Grid.Row="0" ControlMode="Display"
FieldName="EmployeeNumber" IncludeDescription="True"/>

The FormField seems not to be rendered.

share|improve this question

It renders nothing if FormatText is null or empty. Look at the code:

protected override void Render(HtmlTextWriter output)
    if (!string.IsNullOrEmpty(this.FormatText))
        string[] args = new string[this.Controls.Count];
        int index = 0;
        StringBuilder sb = new StringBuilder();
        HtmlTextWriter writer = new HtmlTextWriter(new StringWriter(sb, CultureInfo.InvariantCulture));
        foreach (Control control in this.Controls)
            if (!(control is LiteralControl))
                sb.Length = 0;
                args[index] = sb.ToString();
        string format = null;
        switch (this.EncodeMethod)
            case SPEncodeMethod.NoEncode:
                format = this.FormatText;

            case SPEncodeMethod.HtmlEncode:
                format = SPHttpUtility.HtmlEncode(this.FormatText);

            case SPEncodeMethod.HtmlEncodeAllowSimpleTextFormatting:
                format = SPHttpUtility.HtmlEncodeAllowSimpleTextFormatting(this.FormatText);

            case SPEncodeMethod.EcmaScriptStringLiteralEncode:
                format = SPHttpUtility.EcmaScriptStringLiteralEncode(this.FormatText);
        output.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID);
        string str2 = string.Empty;
            str2 = string.Format(CultureInfo.InvariantCulture, format, args);
        catch (FormatException)
            str2 = string.Format(CultureInfo.InvariantCulture, SPUtility.EscapeForStringFormat(format), args);
share|improve this answer
hi, updated question.... – AGuyCalledGerald Nov 6 '12 at 15:46
Have you tried to display just SharePoint:FormField without SharePoint:FormattedString? – Dmitry Kozlov Nov 6 '12 at 18:13
yes, this works. – AGuyCalledGerald Nov 7 '12 at 9:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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