@{
Layout = null;
ViewData["Title"] = "Car Display Page - Weakly Typed View";
/*
* This example demonstrates using a
Weakly-Typed View to display a collection of Cars.
* The controller passes the collection of Car
objects to this View using the ViewBag.
*
* This View is considered a Weakly-Typed View
because it doesn't have a Model class
* assigned to it.
Views that do not have a Model class assigned to it
can only retrieve data
* from the Controller
using the ViewData/ViewBag
collection.
*
* This View uses two separate Controller
methods to handle the processing of this page.
* The Controller's "GetCars"
method is used to query the database, create a collection of Cars,
* and store the
collection of Cars in the ViewBag that is used in
generating the HTML content for this page
* before it is
delivered to the client.
*
* The View also uses the Controller's "SearchCarsByMake" method to process the HTML form that
is used
* to perform a search
based on the user input for make. The form uses HTTP Post to submit the
* form data to the
Controller's method.
*/
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Car Inventory</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<h1>@ViewData["Title"]</h1>
<br />
<br />
<form method="POST" action="/Cars/SearchCarsByMake">
<input id="searchKey" name="searchKey" type="text" />
<input id="btnSubmit" name="btnSubmit" type="submit" value="Search" />
</form>
<hr />
<table class="table">
<thead>
<tr>
<th>Make:</th>
<th>Model:</th>
<th>Year:</th>
<th>Value:</th>
</tr>
</thead>
<tbody>
@foreach (var car in ViewBag.CarsList)
{
<tr>
<td>
@car.Make
</td>
<td>
@car.Model
</td>
<td>
@car.Year
</td>
<td>
@car.Value.ToString("C2")
</td>
</tr>
}
</tbody>
</table>
</body>
</html>