本文整理汇总了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\"> </td><td colspan=\"2\" class=\"Center\"> </td><td class=\"PropertyRightBottom\"> </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""> </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""> </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""> </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""> </td>
//.........这里部分代码省略.........
示例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();
}
}
}
}
示例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\"> </td><td colspan=\"2\" class=\"Center\"> </td><td class=\"PropertyRightBottom\"> </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""> </td>
<td class=""CategoryTextCell"">" + HTMLHelper.HTMLEncode(fci.CategoryName) + @"</td>
<td class=""CategoryRightBorder""> </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"" > </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""> </td>
</tr>";
if (ffi.Description == null || ffi.Description.Trim() == "")
{
undocumentedProperties++;
}
}
}
}
//.........这里部分代码省略.........
示例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();
}
示例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;
}
}
示例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"))
{
//.........这里部分代码省略.........
示例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