protected void btnLike_Click(object sender, ImageClickEventArgs e) { if (Session["loginuser"] == null) { ScriptManager.RegisterStartupScript(this, this.GetType(), "Poppp", "openLogin();", true); } else { var x = sender as ImageButton; string UID = Session["loginuser"].ToString(); string PID = x.Attributes["imgId"]; string liked = x.ImageUrl; int likes = Convert.ToInt32(lblLikeCount.Text); if (liked == "/Images/unlike.png") { if (LikeClass.sendLike(UID, PID) == true) { x.ImageUrl = "/Images/like.png"; likes += 1; } } else if (liked == "/Images/like.png") { if (LikeClass.UnLike(UID, PID) == true) { x.ImageUrl = "/Images/unlike.png"; likes -= 1; } } lblLikeCount.Text = likes.ToString(); } }
protected void btnLike_Click(object sender, ImageClickEventArgs e) { if (Session["loginuser"] == null) { ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); } else { var x = sender as ImageButton; string UID = x.CommandName; string PID = x.Attributes["imgId"]; string liked = x.ImageUrl; if (liked == "/Images/unlike.png") { if (LikeClass.sendLike(UID, PID) == true) { x.ImageUrl = "/Images/like.png"; ListViewDataItem item = (ListViewDataItem)(sender as Control).NamingContainer; Label lblTLike = (Label)item.FindControl("lblTLike"); lblTLike.Text = SqlTask.getTotalLikeByPhoto(PID).ToString(); } } else if (liked == "/Images/like.png") { if (LikeClass.UnLike(UID, PID) == true) { x.ImageUrl = "/Images/unlike.png"; ListViewDataItem item = (ListViewDataItem)(sender as Control).NamingContainer; Label lblTLike = (Label)item.FindControl("lblTLike"); lblTLike.Text = SqlTask.getTotalLikeByPhoto(PID).ToString(); } } } }