view
This commit is contained in:
@@ -25,7 +25,20 @@ namespace AspNetCoreMVC.Controllers
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Test(int id, [FromHeader] string value)
|
public IActionResult Test()
|
||||||
|
{
|
||||||
|
TestViewModel viewModel = new TestViewModel()
|
||||||
|
{
|
||||||
|
Names = new List<string>()
|
||||||
|
{
|
||||||
|
"One", "Two", "Three"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return View(viewModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Test1(int id, [FromHeader] string value)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -10,4 +10,9 @@ namespace AspNetCoreMVC.Models
|
|||||||
[StringLength(20)]
|
[StringLength(20)]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class TestViewModel
|
||||||
|
{
|
||||||
|
public List<string> Names { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
29
BlazorApp/AspNetCoreMVC/Views/Home/Test.cshtml
Normal file
29
BlazorApp/AspNetCoreMVC/Views/Home/Test.cshtml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
@model TestViewModel
|
||||||
|
@{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@* Render section *@
|
||||||
|
@section Scripts {
|
||||||
|
<h1 style="color:red">I am scripts section!</h1>
|
||||||
|
}
|
||||||
|
|
||||||
|
<h1>Hello Razor Template</h1>
|
||||||
|
<h2>@DateTime.Now This value come from C#</h2>
|
||||||
|
<h3>@(1 + 1)</h3>
|
||||||
|
|
||||||
|
@if (Model.Names.Count < 5)
|
||||||
|
{
|
||||||
|
<h1>a little bit of data</h1>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<h1>a lot of data</h1>
|
||||||
|
}
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
@for (int i = 0; i < Model.Names.Count; i++)
|
||||||
|
{
|
||||||
|
<li>@Model.Names[i]</li>
|
||||||
|
}
|
||||||
|
</ul>
|
13
BlazorApp/AspNetCoreMVC/Views/Home/Test.cshtml.cs
Normal file
13
BlazorApp/AspNetCoreMVC/Views/Home/Test.cshtml.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
using System.Timers;
|
||||||
|
|
||||||
|
namespace AspNetCoreMVC.Views.Home
|
||||||
|
{
|
||||||
|
public class TestModel : PageModel
|
||||||
|
{
|
||||||
|
public void OnGet()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user