Question: For this assignment , you are going to create an MVC Project called Assignment 10 as follows: In the Models folder, create a C# class
For this assignment , you are going to create an MVC Project called Assignment 10 as follows:
In the Models folder, create a C# class called Team with the following two auto - implemented properties:
TeamName
with return type string.
TeamCity
with return type of string.
In the Controllers folder create a controller called HomeController with the following actions
:
Index
,
which is decorated with the [HttpGet] attribute. In its body, it should create an object of type Team and pass it on to its associated view.
Index
,
which is decorated with the [HttpPost] attribute and takes a parameter of type Team.
In its body, it should construct the following message and display it in its associated view.
The team name is X and the team city is Y!
Where X is the TeamName and Y is the TeamCity from the Team object received from the form in its associated view.
In its associated view, the Razor syntax should be used to define a form that has a label for the team name and a text box for it as well as a label for the
team city and a text box for it. It should also have an input of type submit which posts the values entered by the user to the Index action,
decorated with the [HttpPost] attribute . The following block shows the skeleton for theRazor form in this view.
@ using
(Html.BeginForm())
{
<
p
>
Team Name inputs go here
p
>
<
p
>
Team City inputs go here
p
>
<
p
input of type submit goes here
p
>
}
In brief, when the application is run, it shows the form containing the input fields where the user enters a team
name and a team city and clicks the submit input after which the page is refresh ed to show the
message specified earlier.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
