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 trial

C# ASP.NET MVC Basics Modeling and Presenting Data Improving Our View Layout

Why does @Model.Favorite render as false the first time it is ran? I mean, is false the default?

Also, once the code is changed to @(Model.favorite ? "yes" : "no") it renders to "no", which I get because because before it rendered to "false" before. But the new layout code from our "designer" is suppose to be "yes" So what exactly is setting this to false the first run and no the second time, and why does it not expressed properly what the designers want? Here is the markup from the designer: <h5><label>Favorite:</label> Yes</h5>

2 Answers

Steven Parker
Steven Parker
231,269 Points

The field's value is false, and the new code converts it to the word "No". This seems exactly as it should be to me.

So why do you say that it 'is suppose to be "yes"'?

Because the mark up from the "designers" in the teachers notes has this: <h5><label>Favorite:</label> Yes</h>. I took this to mean that the comic book is indeed a favorite.

Steven Parker
Steven Parker
231,269 Points

Good point, but the fault would be in the data, not the code. In fact, I don't see where a "Favorite" property was added to issue 700 at all. Perhaps a missing property just reads as "false" instead of causing an error.

In any case, you might want to make a bug report to the Support staff.