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


C# FormInfo.UpdateExistingFields方法代码示例

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


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

示例1: 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

示例2: BuildFormInfo

    /// <summary>
    /// Returns the form definition for the web part zone properties.
    /// </summary>
    private FormInfo BuildFormInfo(WebPartZoneInstance webPartZone)
    {
        FormInfo fi = null;

        string formDefinition = String.Empty;

        // Dashboard zone properties
        if ((pti != null) && (pti.PageTemplateType == PageTemplateTypeEnum.Dashboard))
        {
            formDefinition = PortalFormHelper.LoadProperties("WebPartZone", "Dashboard.xml");
        }
        // UI page template properties
        else if ((pti != null) && (pti.PageTemplateType == PageTemplateTypeEnum.UI))
        {
            formDefinition = PortalFormHelper.LoadProperties("WebPartZone", "UI.xml");
        }
        // Classic web part/widget properties
        else
        {
            formDefinition = PortalFormHelper.LoadProperties("WebPartZone", "Standard.xml");
        }

        if (!String.IsNullOrEmpty(formDefinition))
        {
            // Load properties
            fi = new FormInfo(formDefinition);
            fi.UpdateExistingFields(fi);

            DataRow dr = fi.GetDataRow();
            LoadDataRowFromWebPartZone(dr, webPartZone);
        }

        return fi;
    }
开发者ID:kbuck21991,项目名称:kentico-blank-project,代码行数:37,代码来源:WebPartZoneProperties.ascx.cs

示例3: BuildFormInfo

    /// <summary>
    /// Returns the form definition for the webpart zone properties.
    /// </summary>
    private FormInfo BuildFormInfo(WebPartZoneInstance webPartZone)
    {
        FormInfo fi = null;

        string formDefinition = String.Empty;

        // Dashboard zone properties
        if ((pti != null) && (pti.PageTemplateType == PageTemplateTypeEnum.Dashboard))
        {
            formDefinition = File.ReadAllText(Server.MapPath("~/CMSModules/PortalEngine/Controls/WebParts/WebPartZone_Dashboard_Properties.xml"));
        }
        // Classic webpart/widget properties
        else
        {
            formDefinition = File.ReadAllText(Server.MapPath("~/CMSModules/PortalEngine/Controls/WebParts/WebPartZone_Properties.xml"));
        }

        if (!String.IsNullOrEmpty(formDefinition))
        {
            // Load properties
            fi = new FormInfo(formDefinition);
            fi.UpdateExistingFields(fi);

            DataRow dr = fi.GetDataRow();
            LoadDataRowFromWebPartZone(dr, webPartZone);
        }

        return fi;
    }
开发者ID:KuduApps,项目名称:Kentico,代码行数:32,代码来源:WebPartZoneProperties.ascx.cs


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