protected void JoinA_Click(object sender, EventArgs e) { Matches match = new Matches(); if (!match.alreadyJoined(user_id, match_id)) // Not joined { match.joinMatch(user_id, match_id, 1); } else // Joined already = Leave then => Join { match.leaveMatch(user_id, match_id); match.joinMatch(user_id, match_id, 1); } Response.Redirect("~/MatchRoom.aspx?match_id=" + match_id); }