コード例 #1
0
        private void rblOptions_SelectedIndexChanged(object sender, EventArgs e)
        {
            // this is where the actual voting happens

            if (String.IsNullOrEmpty(rblOptions.SelectedValue)) return;

            LoadPoll();
            userHasVoted = true;
            Guid selectedOptionGuid = new Guid(rblOptions.SelectedValue);
            PollOption selectedOption = new PollOption(selectedOptionGuid);

            Guid userGuid = Guid.Empty;

            if (currentUser != null)
            {
                userGuid = currentUser.UserGuid;
            }
            else
            {
                // Set a cookie and use it to keep anonymous polls from being too easy
                // to skew. Of course they can still do it
                if (poll.AnonymousVoting)
                {
                    CookieHelper.SetCookie(poll.PollGuid.ToString(), poll.PollGuid.ToString(), true);

                }

            }

            selectedOption.IncrementVotes(userGuid);

            ShowResult();
            pnlPollUpdate.Update();
        }