diff --git a/AspNetFrameworkMVC/AspNetFrameworkMVC/AspNetFrameworkMVC.csproj b/AspNetFrameworkMVC/AspNetFrameworkMVC/AspNetFrameworkMVC.csproj index 2e9cbbb..caab96c 100644 --- a/AspNetFrameworkMVC/AspNetFrameworkMVC/AspNetFrameworkMVC.csproj +++ b/AspNetFrameworkMVC/AspNetFrameworkMVC/AspNetFrameworkMVC.csproj @@ -180,6 +180,7 @@ + diff --git a/AspNetFrameworkMVC/AspNetFrameworkMVC/Controllers/HomeController.cs b/AspNetFrameworkMVC/AspNetFrameworkMVC/Controllers/HomeController.cs index 513bc1f..ffba243 100644 --- a/AspNetFrameworkMVC/AspNetFrameworkMVC/Controllers/HomeController.cs +++ b/AspNetFrameworkMVC/AspNetFrameworkMVC/Controllers/HomeController.cs @@ -96,5 +96,12 @@ namespace AspNetFrameworkMVC.Controllers { return; } + + public ActionResult MyViewRazor(int count) + { + ViewBag.Count = count; + + return View(); + } } } \ No newline at end of file diff --git a/AspNetFrameworkMVC/AspNetFrameworkMVC/Views/Home/MyViewRazor.cshtml b/AspNetFrameworkMVC/AspNetFrameworkMVC/Views/Home/MyViewRazor.cshtml new file mode 100644 index 0000000..251b8cf --- /dev/null +++ b/AspNetFrameworkMVC/AspNetFrameworkMVC/Views/Home/MyViewRazor.cshtml @@ -0,0 +1,61 @@ + +@{ + ViewBag.Title = $"MyViewRazor Count: {ViewBag.Count}"; + string today = DateTime.Now.ToShortDateString(); + + int count = ViewBag.Count; + + string[] list = { "Apple", "Banana", "Coconut", "Durian" }; +} + +

@ViewBag.Title

+

@today

+ +

+ @*조건문*@ + @if (count <= 0) + { +

데이터가 없습니다.
+ + } + else + { +
@count 개의 데이터가 있습니다.
+ + } +
+ + @switch (count) + { + case 1: +
하나
+ break; + case 2: +
+ break; + default: +
셋 이상
+ break; + } +
+ + @for (int i = 0; i < count; i++) + { +
@i
+ } +
+ + @foreach (var elem in list) + { +
Elem: @elem
+ } +
+ + @{ int ix = 1; } + @while (ix < 10) + { +
@ix
+ ix++; + } +

+