Asp.net 将模型中的值检索到视图ib MVC 3中
我是MVC 3的新手,我的视图是Details.aspx,没有Razor引擎Asp.net 将模型中的值检索到视图ib MVC 3中,asp.net,asp.net-mvc,asp.net-mvc-3,Asp.net,Asp.net Mvc,Asp.net Mvc 3,我是MVC 3的新手,我的视图是Details.aspx,没有Razor引擎 public class HomeController : Controller { public ActionResult Index() { return View(); } /* public string Browse() { return "Hello from Browse"; public string Details
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
/* public string Browse()
{
return "Hello from Browse";
public string Details(int id)
{
string message = "Store.Details, ID = " + id;
return message;
// return "Hello from Details";
}*/
public ActionResult Details(int id)
{
var album = new Album { Title = "Album " + id };
return View(album);
}
}
细节
你能给我推荐一个不带razor的MVC3教程吗?在你看来,可以这样做:
<html>
<head runat="server">
<title>Details</title>
</head>
<body>
<div>
</div>
</body>
</html>
@model Your.Namespace.Album
....
@模型名称
在您的视图中,执行以下操作:
<html>
<head runat="server">
<title>Details</title>
</head>
<body>
<div>
</div>
</body>
</html>
@model Your.Namespace.Album
....
@模型名称
由于您没有使用Razor视图引擎(ala MVC 2),您应该可以这样做
在页面顶部
@model Your.Namespace.Album <!--tell the view to use the model - at the very top of the page-->
....
<div>
<!--To print the Title-->
@Model.Title
</div>
…老实说,我假设MVC2中的工作原理与MVC3中的webforms视图引擎相同。我一直用Razor来做MVC3。。。不确定您为什么要避免:S因为您没有使用Razor视图引擎(ala MVC 2),您应该可以这样做 在页面顶部
@model Your.Namespace.Album <!--tell the view to use the model - at the very top of the page-->
....
<div>
<!--To print the Title-->
@Model.Title
</div>
…老实说,我假设MVC2中的工作原理与MVC3中的webforms视图引擎相同。我一直用Razor来做MVC3。。。不确定为什么要避免:S它看起来像:
<div>
<%: Model.Title %>
</div>
它看起来像:
<div>
<%: Model.Title %>
</div>
你是说
?你能给我推荐一个不带剃须刀的MVC3教程吗?你不是说
?你能给我推荐一个不带剃须刀的MVC3教程吗