当前位置: 首页>>代码示例>>C#>>正文


C# FormInfo.GetFormElements方法代码示例

本文整理汇总了C#中FormInfo.GetFormElements方法的典型用法代码示例。如果您正苦于以下问题:C# FormInfo.GetFormElements方法的具体用法?C# FormInfo.GetFormElements怎么用?C# FormInfo.GetFormElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FormInfo的用法示例。


在下文中一共展示了FormInfo.GetFormElements方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateProperties

    /// <summary>
    /// Generate properties.
    /// </summary>
    protected void GenerateProperties(FormInfo fi)
    {
        // Generate script to display and hide  properties groups
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ShowHideProperties", ScriptHelper.GetScript(@"
            function ShowHideProperties(id) {
                var obj = document.getElementById(id);
                var objlink = document.getElementById(id+'_link');
                if ((obj != null)&&(objlink != null)){
                   if (obj.style.display == 'none' ) { obj.style.display=''; objlink.innerHTML = '<img border=""0"" src=""" + minImg + @""" >'; }
                   else {obj.style.display='none'; objlink.innerHTML = '<img border=""0"" src=""" + plImg + @""" >';}
                objlink.blur();}}"));

        // Get defintion elements
        var infos = fi.GetFormElements(true, false);

        bool isOpenSubTable = false;
        bool firstLoad = true;
        bool hasAnyProperties = false;

        string currentGuid = "";
        string newCategory = null;

        // Check all items in object array
        foreach (IFormItem contrl in infos)
        {
            // Generate row for form category
            if (contrl is FormCategoryInfo)
            {
                // Load castegory info
                FormCategoryInfo fci = contrl as FormCategoryInfo;
                if (fci != null)
                {
                    if (isOpenSubTable)
                    {
                        ltlProperties.Text += "<tr class=\"PropertyBottom\"><td class=\"PropertyLeftBottom\">&nbsp;</td><td colspan=\"2\" class=\"Center\">&nbsp;</td><td class=\"PropertyRightBottom\">&nbsp;</td></tr></table>";
                        isOpenSubTable = false;
                    }

                    if (currentGuid == "")
                    {
                        currentGuid = Guid.NewGuid().ToString().Replace("-", "_");
                    }

                    // Generate properties content
                    newCategory = @"<br />
                        <table cellpadding=""0"" cellspacing=""0"" class=""CategoryTable"">
                          <tr>
                            <td class=""CategoryLeftBorder"">&nbsp;</td>
                            <td class=""CategoryTextCell"">" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(fci.CategoryCaption)) + @"</td>
                            <td class=""HiderCell"">
                              <a id=""" + currentGuid + "_link\" href=\"#\" onclick=\"ShowHideProperties('" + currentGuid + @"'); return false;"">
                              <img border=""0"" src=""" + minImg + @""" ></a>
                            </td>
                           <td class=""CategoryRightBorder"">&nbsp;</td>
                         </tr>
                       </table>";
                }
            }
            else
            {
                hasAnyProperties = true;
                // Get form field info
                FormFieldInfo ffi = contrl as FormFieldInfo;

                if (ffi != null)
                {
                    // If display only in dashboard and not dashbord zone (or none for admins) dont show
                    if ((ffi.DisplayIn == "dashboard") && ((zoneType != WidgetZoneTypeEnum.Dashboard) && (zoneType != WidgetZoneTypeEnum.None)))
                    {
                        continue;
                    }
                    if (newCategory != null)
                    {
                        ltlProperties.Text += newCategory;
                        newCategory = null;

                        firstLoad = false;
                    }
                    else if (firstLoad)
                    {
                        if (currentGuid == "")
                        {
                            currentGuid = Guid.NewGuid().ToString().Replace("-", "_");
                        }

                        // Generate properties content
                        firstLoad = false;
                        ltlProperties.Text += @"<br />
                        <table cellpadding=""0"" cellspacing=""0"" class=""CategoryTable"">
                          <tr>
                            <td class=""CategoryLeftBorder"">&nbsp;</td>
                            <td class=""CategoryTextCell"">Default</td>
                            <td class=""HiderCell"">
                               <a id=""" + currentGuid + "_link\" href=\"#\" onclick=\"ShowHideProperties('" + currentGuid + @"'); return false;"">
                               <img border=""0"" src=""" + minImg + @""" ></a>
                            </td>
                            <td class=""CategoryRightBorder"">&nbsp;</td>
//.........这里部分代码省略.........
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:101,代码来源:WebPartDocumentation.ascx.cs

示例2: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        string aliasPath = QueryHelper.GetString("aliaspath", "");
        string webpartId = QueryHelper.GetString("webpartid", "");
        string zoneId = QueryHelper.GetString("zoneid", "");
        Guid webpartGuid = QueryHelper.GetGuid("webpartguid", Guid.Empty);

        // Get page info
        PageInfo pi = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, aliasPath, CMSContext.PreferredCultureCode, null, CMSContext.CurrentSite.CombineWithDefaultCulture);
        if (pi != null)
        {
            // Get template
            PageTemplateInfo pti = pi.GetInheritedTemplateInfo(CMSContext.PreferredCultureCode, CMSContext.CurrentSite.CombineWithDefaultCulture);

            // Get web part
            WebPartInstance webPart = pti.GetWebPart(webpartGuid, webpartId);
            if (webPart != null)
            {
                StringBuilder sb = new StringBuilder();
                Hashtable properties = webPart.Properties;

                // Get the webpart object
                WebPartInfo wi = WebPartInfoProvider.GetWebPartInfo(webPart.WebPartType);
                if (wi != null)
                {
                    // Add the header
                    sb.Append("Webpart properties (" + wi.WebPartDisplayName + ")" + Environment.NewLine + Environment.NewLine);
                    sb.Append("Alias path: " + aliasPath + Environment.NewLine);
                    sb.Append("Zone ID: " + zoneId + Environment.NewLine + Environment.NewLine);

                    string wpProperties = "<default></default>";
                    // Get the form info object and load it with the data

                    if (wi.WebPartParentID > 0)
                    {
                        // Load parent properties
                        WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(wi.WebPartParentID);
                        if (wpi != null)
                        {
                            wpProperties = wpi.WebPartProperties;
                        }
                    }
                    else
                    {
                        wpProperties = wi.WebPartProperties;
                    }

                    FormInfo fi = new FormInfo(wpProperties);

                    // General properties of webparts
                    string beforeFormDefinition = PortalHelper.GetWebPartProperties((WebPartTypeEnum)wi.WebPartType, PropertiesPosition.Before);
                    string afterFormDefinition = PortalHelper.GetWebPartProperties((WebPartTypeEnum)wi.WebPartType, PropertiesPosition.After);

                    // General properties before custom
                    if (!String.IsNullOrEmpty(beforeFormDefinition))
                    {
                        // Load before properties
                        FormInfo bfi = new FormInfo(beforeFormDefinition);
                        bfi.UpdateExistingFields(fi);
                        sb.Append(Environment.NewLine + "Default" + Environment.NewLine + Environment.NewLine + Environment.NewLine);
                        sb.Append(GetProperties(bfi.GetFormElements(true, false), webPart));
                    }

                    // Generate custom properties
                    sb.Append(GetProperties(fi.GetFormElements(true, false), webPart));

                    // General properties after custom
                    if (!String.IsNullOrEmpty(afterFormDefinition))
                    {
                        FormInfo afi = new FormInfo(afterFormDefinition);
                        // Load before properties
                        afi.UpdateExistingFields(fi);

                        sb.Append(GetProperties(afi.GetFormElements(true, false), webPart));
                    }

                    // Send the text file to the user to download
                    UTF8Encoding enc = new UTF8Encoding();
                    byte[] file = enc.GetBytes(sb.ToString());

                    Response.AddHeader("Content-disposition", "attachment; filename=webpartproperties_" + webPart.ControlID + ".txt");
                    Response.ContentType = "text/plain";
                    Response.BinaryWrite(file);

                    RequestHelper.EndResponse();
                }
            }
        }
    }
开发者ID:v-jli,项目名称:jean0407large,代码行数:89,代码来源:GetWebPartProperties.aspx.cs

示例3: GenerateDocContent

    /// <summary>
    /// Generate document content.
    /// </summary>
    /// <param name="wpi">WebPart info</param>
    /// <param name="gd">Guid</param>
    /// <param name="category">Category</param>
    protected void GenerateDocContent(FormInfo fi)
    {
        if (fi == null)
        {
            return;
        }
        // Get defintion elements
        ArrayList infos = fi.GetFormElements(true, false);

        bool isOpenSubTable = false;

        string currentGuid = "";

        // Used for filter empty categories
        String categoryHeader = String.Empty;

        // Check all items in object array
        foreach (object contrl in infos)
        {
            // Generate row for form category
            if (contrl is FormCategoryInfo)
            {
                // Load castegory info
                FormCategoryInfo fci = contrl as FormCategoryInfo;
                if (fci != null)
                {
                    // Close table from last category
                    if (isOpenSubTable)
                    {
                        content += "<tr class=\"PropertyBottom\"><td class=\"PropertyLeftBottom\">&nbsp;</td><td colspan=\"2\" class=\"Center\">&nbsp;</td><td class=\"PropertyRightBottom\">&nbsp;</td></tr></table>";
                        isOpenSubTable = false;
                    }

                    if (currentGuid == "")
                    {
                        currentGuid = Guid.NewGuid().ToString().Replace("-", "_");
                    }

                    // Generate table for current category
                    categoryHeader = @"<br />
                        <table cellpadding=""0"" cellspacing=""0"" class=""CategoryTable"">
                          <tr>
                           <td class=""CategoryLeftBorder"">&nbsp;</td>
                           <td class=""CategoryTextCell"">" + HTMLHelper.HTMLEncode(fci.CategoryName) + @"</td>
                           <td class=""CategoryRightBorder"">&nbsp;</td>
                         </tr>
                       </table>";
                }
            }
            else
            {
                // Get form field info
                FormFieldInfo ffi = contrl as FormFieldInfo;

                if (ffi != null)
                {
                    if (categoryHeader != String.Empty)
                    {
                        content += categoryHeader;
                        categoryHeader = String.Empty;
                    }

                    if (!isOpenSubTable)
                    {
                        // Generate table for properties under one category
                        isOpenSubTable = true;
                        content += "" +
                            "<table cellpadding=\"0\" cellspacing=\"0\" id=\"_" + currentGuid + "\" class=\"PropertiesTable\" >";
                        currentGuid = "";
                    }

                    // Add ':' to caption
                    string doubleDot = "";
                    if (!ffi.Caption.EndsWith(":"))
                    {
                        doubleDot = ":";
                    }

                    content +=
                        @"<tr>
                            <td class=""PropertyLeftBorder"" >&nbsp;</td>
                            <td class=""PropertyContent"" style=""width:200px;"">" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(ffi.Caption)) + doubleDot + @"</td>
                            <td class=""PropertyRow"">" + HTMLHelper.HTMLEncode(resolver.ResolveMacros(DataHelper.GetNotEmpty(ffi.Description, GetString("WebPartDocumentation.DescriptionNoneAvailable")))) + @"</td>
                            <td class=""PropertyRightBorder"">&nbsp;</td>
                        </tr>";

                    if (ffi.Description == null || ffi.Description.Trim() == "")
                    {
                        undocumentedProperties++;
                    }
                }
            }
        }

//.........这里部分代码省略.........
开发者ID:KuduApps,项目名称:Kentico,代码行数:101,代码来源:Documentation.aspx.cs

示例4: ReloadSearch

    /// <summary>
    /// Reload data.
    /// </summary>
    /// <param name="setAutomatically">Indicates whether search options should be set automatically</param>
    public void ReloadSearch(bool setAutomatically)
    {
        ClassFields.ItemID = ItemID;
        ClassFields.ReloadData(setAutomatically, true);

        // Initialize properties
        List<IField> itemList = null;

        if (ClassInfo != null)
        {
            // Load XML definition
            fi = FormHelper.GetFormInfo(ClassInfo.ClassName, true);

            if (CMSString.Compare(ClassInfo.ClassName, "cms.user", true) == 0)
            {
                plcImage.Visible = false;
                ClassFields.DisplaySetAutomatically = false;
                pnlIndent.Visible = true;

                document = DataClassInfoProvider.GetDataClassInfo("cms.usersettings");
                if (document != null)
                {
                    FormInfo fiSettings = FormHelper.GetFormInfo(document.ClassName, true);
                    fi.CombineWithForm(fiSettings, true, String.Empty);
                }
            }

            // Get all fields
            itemList = fi.GetFormElements(true, true);
        }

        if (itemList != null)
        {
            if (itemList.Any())
            {
                pnlIndent.Visible = true;
            }

            // Store each field to array
            foreach (var item in itemList)
            {
                var formField = item as FormFieldInfo;
                if (formField != null)
                {
                    object[] obj = { formField.Name, DataTypeManager.GetSystemType(TypeEnum.Field, formField.DataType) };
                    attributes.Add(obj);
                }
            }
        }

        if (AdvancedMode)
        {
            ReloadControls();
        }
    }
开发者ID:arvind-web-developer,项目名称:csharp-projects-Jemena-Kentico-CMS,代码行数:59,代码来源:SearchFields.ascx.cs

示例5: ReloadSearch

    /// <summary>
    /// Reload data.
    /// </summary>
    /// <param name="setAutomatically">Indicates whether search options should be set automatically</param>
    public void ReloadSearch(bool setAutomatically)
    {
        ClassFields.ItemID = ItemID;
        ClassFields.ReloadData(setAutomatically, true);

        // Initialize properties
        List<IFormItem> itemList = null;
        FormFieldInfo formField = null;

        // Load DataClass
        dci = DataClassInfoProvider.GetDataClass(ItemID);

        if (dci != null)
        {
            // Load XML definition
            fi = FormHelper.GetFormInfo(dci.ClassName, true);

            if (CMSString.Compare(dci.ClassName, "cms.user", true) == 0)
            {
                plcImage.Visible = false;
                ClassFields.DisplaySetAutomatically = false;
                pnlIndent.Visible = true;

                document = DataClassInfoProvider.GetDataClass("cms.usersettings");
                if (document != null)
                {
                    FormInfo fiSettings = FormHelper.GetFormInfo(document.ClassName, true);
                    fi.CombineWithForm(fiSettings, true, String.Empty);
                }
            }

            // Get all fields
            itemList = fi.GetFormElements(true, true);
        }

        if (itemList != null)
        {
            if (itemList.Any())
            {
                pnlIndent.Visible = true;
            }

            // Store each field to array
            foreach (object item in itemList)
            {
                if (item is FormFieldInfo)
                {
                    formField = ((FormFieldInfo)(item));
                    object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) };
                    attributes.Add(obj);
                }
            }
        }

        ReloadControls();
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:60,代码来源:SearchFields.ascx.cs

示例6: LoadParameters

    /// <summary>
    /// Load parameters from data form.
    /// </summary>
    protected void LoadParameters()
    {
        if (ReportInfo != null)
        {
            // Set the form
            FormInfo fi = new FormInfo(ReportInfo.ReportParameters);
            // Get datarow with required columns
            DataRow dr = fi.GetDataRow();
            if (!RequestHelper.IsPostBack() || ForceLoadDefaultValues || !DisplayFilter)
            {
                fi.LoadDefaultValues(dr, true);
            }
            else
            {
                if ((!ForceLoadDefaultValues) && (formElem.DataRow != null))
                {
                    dr = formElem.DataRow;
                }
            }

            // show filter - based on DisplayFilter and number of visible elements
            mDisplayFilterResult = DisplayFilter && (fi.GetFormElements(true, false).Any());

            formElem.DataRow = dr;
            formElem.SubmitButton.Visible = mDisplayFilterResult;
            formElem.SubmitButton.RegisterHeaderAction = false;
            formElem.FormInformation = fi;
            formElem.SubmitButton.Text = GetString("Report_View.btnUpdate");
            formElem.SiteName = CMSContext.CurrentSiteName;
            formElem.ShowPrivateFields = true;
            formElem.Mode = FormModeEnum.Insert;
            formElem.Visible = mDisplayFilterResult;
        }
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:37,代码来源:DisplayReport.ascx.cs

示例7: LoadData

    /// <summary>
    /// Loads data.
    /// </summary>
    private void LoadData()
    {
        // Initialize properties
        ArrayList itemList = null;
        FormFieldInfo formField = null;
        attributes.Clear();

        // Load DataClass
        dci = DataClassInfoProvider.GetDataClass(this.ItemID);

        DataClassInfo tree = null;

        // For 'cms.document' add 'ecommerce.sku' fields, too
        if ((dci != null) && (dci.ClassName == "cms.document"))
        {

            // For 'cms.document' add 'ecommerce.sku' fields, too
            tree = DataClassInfoProvider.GetDataClass("ecommerce.sku");

            if (tree != null)
            {
                // Load XML definition
                fi = FormHelper.GetFormInfo(tree.ClassName, false);
                // Get all fields
                itemList = fi.GetFormElements(true, true);
            }

            if (itemList != null)
            {
                // Store each field to array
                foreach (object item in itemList)
                {
                    if (item is FormFieldInfo)
                    {
                        formField = ((FormFieldInfo)(item));
                        object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) };
                        attributes.Add(obj);
                    }
                }
            }
        }

        if (dci != null)
        {
            // Load XML definition
            fi = FormHelper.GetFormInfo(dci.ClassName, false);
            // Get all fields
            itemList = fi.GetFormElements(true, true);
            ss = new SearchSettings();
            ss.LoadData(dci.ClassSearchSettings);
        }

        if (itemList != null)
        {
            // Store each field to array
            foreach (object item in itemList)
            {
                if (item is FormFieldInfo)
                {
                    formField = ((FormFieldInfo)(item));
                    object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) };
                    attributes.Add(obj);
                }
            }
        }

        // For 'cms.document' add 'cms.tree' fields, too
        if ((dci != null) && (dci.ClassName == "cms.document"))
        {
            tree = DataClassInfoProvider.GetDataClass("cms.tree");

            if (tree != null)
            {
                // Load XML definition
                fi = FormHelper.GetFormInfo(tree.ClassName, false);
                // Get all fields
                itemList = fi.GetFormElements(true, true);
            }

            if (itemList != null)
            {
                // Store each field to array
                foreach (object item in itemList)
                {
                    if (item is FormFieldInfo)
                    {
                        formField = ((FormFieldInfo)(item));
                        object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) };
                        attributes.Add(obj);
                    }
                }
            }
        }

        // For 'cms.user' add 'cms.usersettings' fields, too
        if ((dci != null) && (dci.ClassName.ToLower() == "cms.user"))
        {
//.........这里部分代码省略.........
开发者ID:puentepr,项目名称:kentico-site-example,代码行数:101,代码来源:ClassFields.ascx.cs

示例8: LoadParameters

    /// <summary>
    /// Load parameters from data form.
    /// </summary>
    private void LoadParameters()
    {
        if (ReportInfo != null)
        {
            // Set the form
            FormInfo fi = new FormInfo(ReportInfo.ReportParameters);
            // Get datarow with required columns
            DataRow dr = fi.GetDataRow(false);
            if (!RequestHelper.IsPostBack() || ForceLoadDefaultValues || !DisplayFilter)
            {
                fi.LoadDefaultValues(dr, true);
            }
            else if ((!ForceLoadDefaultValues) && (formParameters.DataRow != null))
            {
                dr = formParameters.DataRow;
            }

            // Show filter - based on DisplayFilter and number of visible elements
            mDisplayFilterResult = DisplayFilter && (fi.GetFormElements(true, false).Any());

            formParameters.DataRow = dr;
            formParameters.SubmitButton.Visible = mDisplayFilterResult;
            formParameters.SubmitButton.RegisterHeaderAction = false;
            formParameters.FormInformation = fi;
            formParameters.SubmitButton.ResourceString = "report_view.btnupdate";
            formParameters.SiteName = SiteContext.CurrentSiteName;
            formParameters.Mode = FormModeEnum.Insert;
            formParameters.Visible = mDisplayFilterResult;

            wasInit = true;
        }
    }
开发者ID:arvind-web-developer,项目名称:csharp-projects-Jemena-Kentico-CMS,代码行数:35,代码来源:DisplayReport.ascx.cs


注:本文中的FormInfo.GetFormElements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。