private Panel InvokeGetPropertyPanelSelect() { var propdoc = CreateTestDocument(SelectType); var props = new Hashtable(); props[DummyString] = True; ShimTemplateControl.AllInstances.LoadControlString = (_, __) => new StubInputFormSection(); var page = new LayoutsPageBase(); var request = new HttpRequest(string.Empty, ExampleUrl, null); ShimHttpRequest.AllInstances.ItemGetString = (_, __) => _dummyGuid.ToString(); ShimPage.AllInstances.RequestGet = _ => new HttpRequest(string.Empty, ExampleUrl, string.Empty); // Act return(_testObject.GetPropertyPanel(propdoc.ChildNodes[0], props, page)); }
internal Panel GetPropertyPanel(XmlNode ndProps, Hashtable hshProps, LayoutsPageBase page) { Panel pnl = new Panel(); pnl.Controls.Add(new LiteralControl("<table width=\"100%\">")); hshProperties = hshProps; foreach (XmlNode ndProperty in ndProps.SelectNodes("Input")) { string Property = GetNodeAttribute(ndProperty, "Property"); string Title = GetNodeAttribute(ndProperty, "Title"); string Type = GetNodeAttribute(ndProperty, "Type"); string ParentProperty = GetNodeAttribute(ndProperty, "ParentProperty"); InputFormSection section = (InputFormSection)page.LoadControl("~/_controltemplates/InputFormSection.ascx"); section.ID = Property + "_Section"; section.Title = Title; IntegrationDescriptionTemplate controlDescription = new IntegrationDescriptionTemplate(ndProperty.InnerText); section.Template_Description = controlDescription; string curVal = ""; if (page.IsPostBack) { curVal = page.Request[""]; } else { try { curVal = hshProps[Property].ToString(); } catch { } } hshProps[Property] = curVal; Control c = null; switch (Type.ToLower()) { case "text": TextBox txt = new TextBox(); txt.ID = Property; txt.Text = curVal; c = txt; break; case "password": TextBox txt1 = new TextBox(); txt1.ID = Property; txt1.TextMode = TextBoxMode.Password; if (page.IsPostBack) { txt1.Text = curVal; } c = txt1; break; case "textarea": TextBox txt4 = new TextBox(); txt4.ID = Property; txt4.TextMode = TextBoxMode.MultiLine; txt4.Columns = 30; txt4.Rows = 4; txt4.Text = curVal; c = txt4; break; case "select": DropDownList ddl = new DropDownList(); ddl.ID = Property; //TODO: parent property Dictionary <String, String> props = _core.GetDropDownProperties(ModuleID, intlistid, new Guid(page.Request["List"]), Property, ""); foreach (KeyValuePair <String, String> prop in props) { System.Web.UI.WebControls.ListItem li = new System.Web.UI.WebControls.ListItem(prop.Value.ToString(), prop.Key.ToString()); if (curVal == prop.Key.ToString()) { li.Selected = true; } ddl.Items.Add(li); } ddl.EnableViewState = true; c = ddl; break; case "checkbox": CheckBox chk = new CheckBox(); chk.ID = Property; try { chk.Checked = bool.Parse(curVal); } catch { } c = chk; break; default: TextBox txt3 = new TextBox(); txt3.ID = Property; txt3.Text = curVal; c = txt3; break; } ControlCollection.Add(c); IntegrationControlTemplate controlTemplate = new IntegrationControlTemplate(c, page, Title); section.Template_InputFormControls = controlTemplate; pnl.Controls.Add(section); } pnl.Controls.Add(new LiteralControl("</table>")); return(pnl); }