protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { if (!usuario_sesion.isFriend(int.Parse(Request.QueryString["id"]))) { Response.Redirect("../Asp_forms/Friends.aspx?all=yes"); } User_Class usuario_friend = new User_Class(); usuario_friend = usuario_friend.getUser(int.Parse(Request.QueryString["id"])); Image1.ImageUrl = usuario_friend.Image_url; Label1.Text = usuario_friend.Nick; Label2.Text = usuario_friend.Name; Label3.Text = usuario_friend.Surname; Label4.Text = usuario_friend.Email; Label5.Text = usuario_friend.Gender.ToString(); Label6.Text = usuario_friend.Entry_date; Label7.Text = usuario_friend.Birth_date; } else { Response.Redirect("../Account/Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie userCookie; HttpCookie passCookie; userCookie = Request.Cookies["UserID"]; passCookie = Request.Cookies["UserPass"]; if (userCookie == null || passCookie == null) { Response.Redirect("../Account/Login.aspx"); } else { User_Class usuario_sesion = new User_Class(); usuario_sesion = usuario_sesion.getUser(userCookie.Value); if (usuario_sesion.Pass == passCookie.Value) { if (Request.QueryString["all"] == "yes") RadioButtonList1.Items[1].Selected = true; else RadioButtonList1.Items[0].Selected = true; if (RadioButtonList1.Text == "Only my friends") { List<User_Class> lista = new List<User_Class>(); usuario_sesion.getFriends(); if (Request.QueryString["cadena"] != null) { lista = filterFriends(Request.QueryString["cadena"], usuario_sesion.Friends); } else { lista = usuario_sesion.Friends; } if (lista.Count() == 0) { Label label = new Label(); label.Attributes.Add("style", "float:center; margin-left:50px;"); label.ID = "LabelX"; label.Text = "<h2> No friends found! </h2>"; Panel2.Controls.Add(label); } HyperLink link = new HyperLink(); for (int j = 0; j < lista.Count(); j++) { link=new HyperLink(); link.Text=lista.ElementAt(j).Name; link.NavigateUrl="~//Asp_forms/UserTable.aspx/?ID="+lista.ElementAt(j).Id.ToString(); link.Attributes.Add("style", "clear:both; margin-left:50px;"); Panel p = createPanel(); Panel2.Controls.Add(p); p.Controls.Add(createImage(lista.ElementAt(j).Image_url)); p.Controls.Add(link); p.Controls.Add(createPrfButton(lista.ElementAt(j).Id)); p.Controls.Add(createDelButton(lista.ElementAt(j).Id)); } } else if (RadioButtonList1.Text == "All Users") { List<User_Class> lista = new List<User_Class>(); if (Request.QueryString["cadena"] != null) { lista = filterFriends(Request.QueryString["cadena"], usuario_sesion.getAllUser()); } else { lista = usuario_sesion.getAllUser(); } HyperLink link = new HyperLink(); for (int j = 0; j < lista.Count(); j++) { link = new HyperLink(); link.Text = lista.ElementAt(j).Name; link.NavigateUrl = "~//Asp_forms/UserTable.aspx/?ID=" + lista.ElementAt(j).Id.ToString(); link.Attributes.Add("style", "clear:both; margin-left:50px;"); Panel p = createPanel(); Panel2.Controls.Add(p); p.Controls.Add(createImage(lista.ElementAt(j).Image_url)); p.Controls.Add(link); if (usuario_sesion.isFriend(lista.ElementAt(j).Id)) { p.Controls.Add(createPrfButton(lista.ElementAt(j).Id)); } if (!usuario_sesion.isFriend(lista.ElementAt(j).Id)) { p.Controls.Add(createAddButton(lista.ElementAt(j).Id)); } else { p.Controls.Add(createDelButton(lista.ElementAt(j).Id)); } } } } else { Response.Redirect("../Account/Login.aspx"); } } }