Quiz Study Guide

advertisement
List of some possible questions for the ‘Edit Action’ lecture
1. Given the code listed below, how will the displayed web
page differ when it’s rendered WITH and WITHOUT the
line next to the 1
2. Given the code listed below, how will the displayed web
page differ when it’s rendered WITH and WITHOUT the
line next to the 2
using System;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
namespace MvcMovie.Models
{
public class Movie
{
public int ID { get; set; }
public string Title { get; set; }
[Display(Name = "Release Date")]
2
1
[DataType(DataType.Date)]
public DateTime ReleaseDate { get; set; }
public string Genre { get; set; }
public decimal Price { get; set; }
}
public class MovieDBContext : DbContext
{
public DbSet<Movie> Movies { get; set; }
}
}
3. Given the code listed below, how will the displayed web
page differ when it’s rendered WITH the following line of
code (instead of the “1” or “2” listed above):
[DisplayFormat( DataFormatString = "{0:yyyy-MM-dd}",
ApplyFormatInEditMode = true)]
1 and
2
4.
What are the things listed above next to
called?
5.
Explain one advantage that declarative programming has
over imperative programming
6.
What is the purpose of reflection?
7.
What does the DisplayFormat do?
8. Given one of the formatting strings from the slides, what date output does it produce?
(I might re-arrange the stuff we saw in class: “{0:MM yyyy ? dd}”
Note: include displayformat, etc
9. Describe attributes – remember the name
[Display(Name="Release Date")]
10. What is a reflection?
Allows your program to see all the metadata: class names, properties, method names
Then you can use that metadata in your code
11. What html is generated by
In Views/Movies/Index.cshtml:
<td>
<a asp-action="Edit" asp-route-id="@item.ID">Edit</a> |
</td>
<td><a href="/Movies/Edit/2">Edit</a></td>
12. What does asp-action mean?
13. What does asp-route-id mean?
14. What does asp-controller mean?
15. What does doe the anchor helper tag do in the viewsMovie ClassIndex.cshtml file?
This builds the URL based on the routing info in the in the Startup.CS class.
16. In what class can you actually define a named route that includes a controller and
action.
And in what programming language is this accomplished in?
You can do this in the startup.cs file, using the following code:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
sdf
Download