Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a web page using ASP.NET where the users can vote for 1 or more candidates and display their respective vote counts from a text

Create a web page using ASP.NET where the users can vote for 1 or more candidates and display their respective vote counts from a text file.

Given the following Razer C# codes, please help to make amendments so that it will display the outputs shown below:

votepage.cshtml

@{ var result = ""; if (IsPost) { var cand1 = Request["cand1"]; var cand2 = Request["cand2"]; var cand3 = Request["cand3"];

var userData = cand1 + "-" + cand2 + "-" + cand3 + Environment.NewLine;

var dataFile = Server.MapPath("~/App_Data/data.txt"); File.AppendAllText(@dataFile, userData); result = "Information saved."; } }

Voting Poll

Choose Your Vote

Candidate 1


Candidate 2


Candidate 3



@if (result != "") {

Result: @result

}

---------------------------------------------------------------------------------------------------------------------------------------------------

To store and display the vote counts for each candidates using data.txt file in the format below:

image text in transcribed

--------------------------------------------------------------------------------------------------------------------------

Desired Outputs:

Before the user votes

image text in transcribed

After the user votes and clicks on the show vote count button:

image text in transcribed

data - Notepad File Edit Format View Help Candidate 1 - Vote Count: 1 Candidate 2 Vote Count: 3 Candidate 3 Vote Count: 7 Choose Your Vote Candidate 1 Candidate 2 Candidate 3 Vote Vote Vote Show Vote Count Choose Your Vote Candidate 1 Candidate 2 Candidate 3 Vote Vote Vote Show Vote Count Candidate 1 - Vote Count: 1 Candidate 2 - Vote Count: 3 Candidate 3 - Vote Count: 7

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions

Question

Were they made on a timely basis?

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago