MVC 4 ViewBag รับและแสดงค่าในหน้าเว็บ
สามารถแสดงผลจาก object public ActionResult Index() { List<String> s2 = new List<string>() { "a", "b", "c" }; ViewBag.MyData = "Hello"; ViewBag.MyData2 = s2; return View();//แบบแรก } ในส่วนของ View เรียกใช้ @{…
MVC 4.0 Map Route
New Project MVC Application c# Right Click Controllers ->Add->Controller->Student Add View ใส่โค้ดตามตัวอย่าง using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace MvcApplication1.Controllers { public class StudentController : Controller…