/// <summary> /// 关注其他用户 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void FollowBtn_Click(object sender, EventArgs e) { if (!IsSignIn()) { Response.Redirect("/layout/SignIn.aspx"); return; } else { Button btn = (Button)sender; User user = (User)Session["User"]; if (btn.Text.Trim() == "关注") { string _followingId = btn.Attributes["data-user-id"].ToString(); Int64 followingId = !String.IsNullOrEmpty(_followingId) ? Int64.Parse(_followingId) : 0; if (followingId == 0 || followingId == user.Id) // 不能关注自己 { return; } Follow follower = new Follow() { UserId = user.Id, FollowingId = followingId }; bool isOk = FollowService.Following(follower); if (isOk) { btn.Text = "已关注"; } } else { // TODO: 取消关注 } } }