More in this section

Forums / General Discussions / How to get form control ordinal position on page?

How to get form control ordinal position on page?

2 posts, 0 answered
  1. Basem
    Basem avatar
    131 posts
    22 Dec 2010
    16 Mar 2011
    Link to this post
    I am trying to sort a form's control collection based on where it is placed on the form.
    I am first getting my form control programmatically like this:
    var form = FormsManager.GetManager().GetFormByName("sf_testform");
    When getting the control though, they are returned in a random order it seems. How do I sort them by their ordinal positioning on the page?
    var controls = form.Controls.OrderBy(c => c.???)
    I tried using the "PositionInSection" in MetaField, but it is blank unless explicitly defined:
    var formControls = form.Controls.OrderBy(c => c.Properties.GetMetaValue("PositionInSection"));
    public static string GetMetaValue(this IList<ControlProperty> property, string key)
        var metaField = property.FirstOrDefault(p => p.Name == "MetaField");
        string value = String.Empty;
        if (metaField != null)
            var childProperty = metaField.ChildProperties.FirstOrDefault(c => c.Name == key);
            if (childProperty != null)
                value = childProperty.Value;
        return value;
    Do the form controls have an ordinal position that I can use to sort?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    17 Mar 2011
    Link to this post
    Hello Basem,

    There is no method that you can use to return the forms by the order they are displayed on a page. I would suggest that you should check RenderFormFields() of Telerik.Sitefinity.Modules.Forms.Web.UI.FormsControl

    Best wishes,
    Ivan Dimitrov
    the Telerik team
2 posts, 0 answered