protected void buttonEnviar_Click(object sender, EventArgs e) { if (this.IsValid) { Reclamacion r = new Reclamacion(); r.Asunto = this.radioList.SelectedValue; r.Mensaje = this.inputMensaje.Text; r.Nombre = this.inputNombre.Text; r.Apellido = this.inputApe1.Text; r.DNI = this.inputDNI.Text; r.Provincia = this.inputProvincia.Text; r.Localidad = this.inputLoc.Text; r.Telefono = this.inputTlf.Text; r.Email = this.inputMail.Text; //si es valida creo objeto Reclamacion y lo mando a controlFIchero //para guardarlo en el fichero __controlFichero.grabaReclamacion(r, ruta); this.inputMensaje.Text = "Mensaje enviado con éxito"; } else { return; } }
//FICHERO RECLAMACIONES.xml public bool grabaReclamacion(Reclamacion r, string ruta) { XmlDocument doc = new XmlDocument(); doc.Load(HttpContext.Current.Request.MapPath(ruta)); XmlElement reclamacion = doc.CreateElement("reclamacion"); XmlNode asunto = doc.CreateNode("element", "asunto", ""); asunto.InnerText = r.Asunto; XmlNode mensaje = doc.CreateNode("element", "mensaje", ""); mensaje.InnerText = r.Mensaje; XmlNode nombre = doc.CreateNode("element", "nombre", ""); nombre.InnerText = r.Nombre; XmlNode email = doc.CreateNode("element", "email", ""); email.InnerText = r.Email; reclamacion.AppendChild(asunto); reclamacion.AppendChild(mensaje); reclamacion.AppendChild(nombre); reclamacion.AppendChild(email); XmlElement root = doc.DocumentElement; root.AppendChild(reclamacion); doc.Save(HttpContext.Current.Request.MapPath(ruta)); return true; }