protected void Page_Load(object sender, EventArgs e) { controlFichero = new ControladorFicheros(); total = this.Request.QueryString["total"]; email = this.Request.QueryString["cliente"]; c = controlFichero.getCliente(email, ruta); this.lblPrecioTotal.Text = total; this.lblDireccion.Text = c.Direccion; this.lblCliente.Text = c.Nombre; }
protected void Page_Load(object sender, EventArgs e) { tree = (TreeView)this.Master.FindControl("TreeView1"); Label lblDireccion = (Label)this.Master.FindControl("LabelDireccion"); controlFichero = new ControladorFicheros(); cargaControlCarrito(); if (!this.IsPostBack) { email = this.Request.QueryString["usuario"]; cliente = controlFichero.getCliente(email, rutaXML); lblDireccion.Text = "Usuario: " + cliente.Nombre + ". Direccion: " + cliente.Direccion; cargaTree(); ViewState["listaproductos"] = new List<Producto>(); } else if (this.IsPostBack) { //si es postback se me borra la cesta //la cargo SIEMPRE l = (List<Producto>)ViewState["listaproductos"]; actualizaCarrito(l); foreach (string clave in this.Request.Params.AllKeys) { string subseccion; string claveRequest = this.Request.Params[clave]; switch (clave) { case "__EVENTTARGET": if (claveRequest.Contains(tree.ID)) { char[] separador = new char[] { '\\' }; try { subseccion = this.Request.Params["__EVENTARGUMENT"].ToString().Split(separador)[1]; Session["subActual"] = subseccion; } catch (IndexOutOfRangeException) { return; } lista = controlFichero.getProductoSubseccion(subseccion, rutaSecciones); rellenaTablaConProductos(lista); } break; default: break; } if (claveRequest.Equals("Añadir")) { //significa que han añadido algo // tengo que tener un 'actualizaCEsta', que lea el ViewState string descripcion = clave.Split(new char[] { '$' })[3]; string sub = (string)Session["subActual"]; lista = controlFichero.getProductoSubseccion(sub, rutaSecciones); Producto p = (from prod in lista where prod.Descripcion == descripcion select prod).Single(); // almacenar en una listaViewState los objetos pulsados addToViewState(p);//--> solo añado, Actualizo cuando hace postback // por otro lado leer la lista para cargar el controlCesta l = (List <Producto> )ViewState["listaproductos"]; actualizaCarrito( l ); rellenaTablaConProductos(lista); } if ( clave.Contains("BtnFormalizarPedido" ) ) { string mail = this.Request.QueryString["usuario"]; cliente = controlFichero.getCliente(mail, rutaXML); this.Response.Redirect("Formalizar.aspx?cliente="+cliente.Email+"&total="+this.control.Total); } } } }