- , ;
- , (repondezs'ilvousplait - RSVP);
- RSVP, ;
- RSVP .
MVC, , . , , - HTML- . Views/Home/Index.cshtml .
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="/>
<title>Index</title>
</head>
<body>
<div>
@ViewBag.Greeting ( )
<p> .</p>
</div>
</body>
</html>
. , - , , .
MVC "M" model (), . - , , , .
, , C# ( ), "" , , . , MVC , .
PartyInvites , , , GuestResponse. , (RSVP).
MVC , , Models, VisualStudio . Models SolutionExplorer Add, Class (). GuestResponse.cs Add, .
Class , VisualStudio . VisualStudio , .
|
|
, :
namespacePartyInvites.Models
{
public class GuestResponse
{
public string Name { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public bool? WillAttend{ get; set; }
}
}
, WillAttend bool, null, .. true, false null. " " .
RSVP, Index.cshtml, :
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="/>
<title>Index</title>
</head>
<body>
<div>
@ViewBag.Greeting ( )
<p> .</p>
@Html.ActionLink(" RSVP", "RsvpForm")
</div>
</body>
</html>
Html.ActionLink() - HTML. MVC Framework , , , , HTML-. ActionLink : ( ), , - , , .
, , , :
, , http://-/Home/RsvpForm. Html.ActionLink() URL , /Home/RsvpForm URL RsvpForm HomeController.
, ASP.NET, URL- MVC . URL, MVC ASP.NET URL .
404 NotFound ( ). , , URL /Home/RsvpForm. RsvpForm HomeController, :
using System;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.Mvc; namespacePartyInvites.Controllers{publicclassHomeController: Controller {publicViewResultIndex(){int hour = DateTime.Now.Hour;ViewBag.Greeting = hour<12?" ":" ";return View(); } publicViewResultRsvpForm(){returnView(); } }}