Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 将模型中的值检索到视图ib MVC 3中_Asp.net_Asp.net Mvc_Asp.net Mvc 3 - Fatal编程技术网

Asp.net 将模型中的值检索到视图ib MVC 3中

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

我是MVC 3的新手,我的视图是Details.aspx,没有Razor引擎

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教程吗