namespace StateManagement

{

    public partial class ApplicationExample1 : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

 

        }

 

        protected void btnRecordVote_Click(object sender, EventArgs e)

        {

            // Lock the Application object so no other updating can be done to this object.

            Application.Lock();

 

            // Retrieve & update the total number of votes from all users of the web application.

            int count = (int)Application["VoteCount"];

            count = count + 1;

            Application["VoteCount"] = count;

 

            // Retrieve & update the specific candidate's vote count.

            String candidate = rboCandidates.SelectedValue.ToString();

            int candidateVoteCount = (int)Application[candidate];

            candidateVoteCount = candidateVoteCount + 1;

            Application[candidate] = candidateVoteCount;

 

            // Unlock the Application object so others can use it.

            Application.UnLock();

 

            Response.Redirect("ApplicationExample1_Results.aspx");

        }

    }

}