/// <summary> /// Update the XML resource file with the appropriate data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void DynamicEdit_Submit(object sender, EventArgs e) { if (!AdminUtil.IsAdminLoggedIn()) { throw new Exception("Cannot modify XML - Admin not logged in."); } //get the sender control DynamicEdit control = (DynamicEdit)((WebControl)sender).NamingContainer; //get the Key from the control String key = control.Key; //open the appropriate language XML file XmlDocument doc = new XmlDocument(); string filename = Localization.ResourceManager.GetCurrentFilename(); doc.PreserveWhitespace = true; doc.Load(filename); //find the node with the matching key XmlNode node = doc.SelectSingleNode("Resource/item[@name='" + key + "']"); if (node != null) { //enter this data into the node node.InnerXml = control.EditText; } else { //else create a node with the key XmlNode root = doc.SelectSingleNode("Resource"); XmlElement item = doc.CreateElement("item"); item.SetAttribute("name", key); item.InnerXml = control.EditText; root.AppendChild(item); } //save the xml file doc.Save(filename); //clear the cache of text Localization.ResourceManager.ClearCache(); }
protected override void OnInit(EventArgs e) { base.OnInit(e); //Set the language - early in the page cycle this.DoLanguage(); ((TBWebMaster)(this.Master)).SetLanguageHeader(); //if admin is logged in, don't enforce loading of default culture info if (AdminUtil.IsAdminLoggedIn()) { Localization.ResourceManager.LoadDefault = false; } //activate all DynamicEdit controls that OnSubmit //should call the event handler in this class /* if (AdminUtil.IsAdminLoggedIn()) * { * //loop through the page for DynamicEdit controls * //and set their OnSubmit to this object * IEnumerator allCtrls = DynamicEditControls.GetEnumerator(); * * * while (allCtrls.MoveNext()) * { * DynamicEdit de = (DynamicEdit)allCtrls.Current; * * de.OnSubmit += new EventHandler(DynamicEdit_Submit); * } * * }*/ }