/// <summary> /// Saves this instance. /// </summary> public override void Save() { // set the options var options = new XmlDropDownListOptions(true); // save the options options.XmlFilePath = this.PathPickerXmlFilePath.Value; options.XPathExpression = this.TextBoxXPathExpression.Text; options.TextColumn = this.TextBoxTextColumn.Text; options.ValueColumn = this.TextBoxValueColumn.Text; // save the options as JSON this.SaveAsJson(options); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); // get PreValues, load them into the controls. var options = this.GetPreValueOptions <XmlDropDownListOptions>(); // no options? use the default ones. if (options == null) { options = new XmlDropDownListOptions(true); } // set the values this.PathPickerXmlFilePath.Value = options.XmlFilePath; this.TextBoxXPathExpression.Text = options.XPathExpression; this.TextBoxTextColumn.Text = options.TextColumn; this.TextBoxValueColumn.Text = options.ValueColumn; }
/// <summary> /// Handles the Init event of the m_Control control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void m_Control_Init(object sender, EventArgs e) { var options = ((XmlDropDownListPrevalueEditor)this.PrevalueEditor).GetPreValueOptions <XmlDropDownListOptions>(); if (options == null) { // load defaults options = new XmlDropDownListOptions(true); } if (!string.IsNullOrWhiteSpace(options.XmlFilePath) && !string.IsNullOrWhiteSpace(options.XPathExpression)) { var path = IOHelper.MapPath(options.XmlFilePath); if (File.Exists(path)) { var xml = new XmlDocument(); xml.Load(path); this.m_Control.Items.Clear(); this.m_Control.Items.Add(new ListItem(string.Concat(ui.Text("choose"), "..."), string.Empty)); foreach (XmlNode node in xml.SelectNodes(options.XPathExpression)) { var text = GetValueFromAttributeOrXPath(node, options.TextColumn); var value = GetValueFromAttributeOrXPath(node, options.ValueColumn); this.m_Control.Items.Add(new ListItem(text, value)); } if (base.Data.Value != null) { this.m_Control.SelectedValue = base.Data.Value.ToString(); } } } }
private void m_Control_Init(object sender, EventArgs e) { var options = ((XmlDropDownListPrevalueEditor)this.PrevalueEditor).GetPreValueOptions <XmlDropDownListOptions>(); if (options == null) { // load defaults options = new XmlDropDownListOptions(true); } if (!string.IsNullOrWhiteSpace(options.XmlFilePath) && !string.IsNullOrWhiteSpace(options.XPathExpression)) { var path = IOHelper.MapPath(options.XmlFilePath); if (File.Exists(path)) { using (var xml = new XmlDataSource() { DataFile = path, XPath = options.XPathExpression }) { this.m_Control.DataSource = xml; this.m_Control.DataTextField = options.TextColumn; this.m_Control.DataValueField = options.ValueColumn; this.m_Control.DataBind(); this.m_Control.Items.Insert(0, new ListItem(string.Concat(ui.Text("choose"), "..."), string.Empty)); } if (base.Data.Value != null) { this.m_Control.SelectedValue = base.Data.Value.ToString(); } } } }
/// <summary> /// Handles the Init event of the m_Control control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void m_Control_Init(object sender, EventArgs e) { var options = ((XmlDropDownListPrevalueEditor)this.PrevalueEditor).GetPreValueOptions<XmlDropDownListOptions>(); if (options == null) { // load defaults options = new XmlDropDownListOptions(true); } if (!string.IsNullOrWhiteSpace(options.XmlFilePath) && !string.IsNullOrWhiteSpace(options.XPathExpression)) { var path = IOHelper.MapPath(options.XmlFilePath); if (File.Exists(path)) { var xml = new XmlDocument(); xml.Load(path); this.m_Control.Items.Clear(); this.m_Control.Items.Add(new ListItem(string.Concat(ui.Text("choose"), "..."), string.Empty)); foreach (XmlNode node in xml.SelectNodes(options.XPathExpression)) { var text = GetValueFromAttributeOrXPath(node, options.TextColumn); var value = GetValueFromAttributeOrXPath(node, options.ValueColumn); this.m_Control.Items.Add(new ListItem(text, value)); } if (base.Data.Value != null) { this.m_Control.SelectedValue = base.Data.Value.ToString(); } } } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); // get PreValues, load them into the controls. var options = this.GetPreValueOptions<XmlDropDownListOptions>(); // no options? use the default ones. if (options == null) { options = new XmlDropDownListOptions(true); } // set the values this.PathPickerXmlFilePath.Value = options.XmlFilePath; this.TextBoxXPathExpression.Text = options.XPathExpression; this.TextBoxTextColumn.Text = options.TextColumn; this.TextBoxValueColumn.Text = options.ValueColumn; }