Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialshawn khah
15,082 Pointscan't solve challenge 2 of 2
Update the Detail.cshtml view to use the ViewBag data. Remove the title, description, and characters variables. Replace the title, description, and characters references with the respective ViewBag properties. Important: In each task of this code challenge, the code you write should be added to the code from the previous task. Restart Preview Get Help Check Work VideoGamesController.cs Detail.cshtml
1 @{ 2 Layout = null; 3
4 var title = "Super Mario 64"; 5 var description = "Super Mario 64 is a 1996 platform video game developed and published by Nintendo for the Nintendo 64."; 6 var characters = new string[] 7 { 8 "Mario", 9 "Princess Peach", 10 "Bowser", 11 "Toad", 12 "Yoshi" 13 }; 14 } 15 16 <!DOCTYPE html> 17 18 <html> 19 <head> 20 <meta name="viewport" content="width=device-width" /> 21 <title>Video Game Detail</title> 22 </head> 23 <body> 24 <div> 25 <h1>@title</h1> 26
27 <h5>Description:</h5> 28 <div>@description</div> 29
30 <h5>Characters:</h5> 31 <div> 32 <ul> 33 @foreach (var character in characters) 34 { 35 <li>@character</li> 36 } 37 </ul> 38 </div> 39 </div> 40 </body> 41 </html> 42
using System.Web.Mvc;
namespace Treehouse.Controllers
{
public class VideoGamesController : Controller
{
public ActionResult Detail()
{
ViewBag.Title = "Super Mario 64";
ViewBag.Description = "Super Mario 64 is a 1996 platform video game developed and published by Nintendo for the Nintendo 64.";
ViewBag.Characters = new string[]
{
"Mario",
"Princess Peach",
"Bowser",
"Toad",
"Yoshi"
};
return View();
}
}
}
@{
Layout = null;
var title = "Super Mario 64";
var description = "Super Mario 64 is a 1996 platform video game developed and published by Nintendo for the Nintendo 64.";
var characters = new string[]
{
"Mario",
"Princess Peach",
"Bowser",
"Toad",
"Yoshi"
};
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Video Game Detail</title>
</head>
<body>
<div>
<h1>@title</h1>
<h5>Description:</h5>
<div>@description</div>
<h5>Characters:</h5>
<div>
<ul>
@foreach (var character in characters)
{
<li>@character</li>
}
</ul>
</div>
</div>
</body>
</html>
1 Answer
James Churchill
Treehouse TeacherShawn,
Were you able to get past this code challenge? If not, what have you tried? Did you receive an error message?
Thanks ~James