.


:




:

































 

 

 

 


- . MVC , HTML-.

ViewBag, ControllerBase.

ViewBag - , , . HomeController.cs .

using System;

usingSystem.Collections.Generic;

usingSystem.Linq;

usingSystem.Web;

usingSystem.Web.Mvc;

 

namespacePartyInvites.Controllers

{

public class HomeController: Controller

{

publicViewResult Index()

{

int hour = DateTime.Now.Hour;

ViewBag.Greeting = hour< 12? " ": " ";

returnView();

}

}

}

 

ViewBag.Greeting . Greeting , - , . , ViewBag.Greeting, , , , Index.cshtml:

@{

Layout = null;

}

 

<!DOCTYPE html>

 

<html>

<head>

<meta name="viewport" content="/>

<title>Index</title>

</head>

<body>

<div>

@ViewBag.Greeting ( )

</div>

</body>

</html>

, - Razor. Index() View(), MVC Index.cshtml Razor . Razor , , .

, ViewBag.Greeting .

Greeting . , , , , , . , . :

 

 



<== | ==>
|
:


: 2018-11-12; !; : 176 |


:

:

,
==> ...

1833 - | 1739 -


© 2015-2024 lektsii.org - -

: 0.008 .