2012-07-13 49 views
-1

嗨,我有一個剃鬚刀文件Index.cshtml需要轉換爲aspx ...任何人都可以幫助我如何聲明類和模型.cshtml中的每一件事.aspx將剃鬚刀轉換爲MVC3中的aspx

這裏是我的Index.cshtml代碼

Index.cshtml


@model IEnumerable<Gridview_BugTracker.Models.BugTracker_DataHelper> 
@{ 
    ViewBag.Title = "Projects"; 
}   

<p> 
    @Html.ActionLink("Create New", "Create") 
</p> 
<table> 
    <tr> 
     <th> 
      ProjectName 
     </th> 
     <th> 
      Description  
     </th> 
     <th> 
      Status 
     </th> 
    </tr> 

    @foreach (var item in Model) 
    { 
    <tr> 
     <td> 
      @Html.DisplayFor(modelItem => item.projectName) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.Description) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.status) 
     </td>  
     <td> 
      @Html.ActionLink("Edit", "Edit", new { id = item.projectName }) | 
      @Html.ActionLink("Details", "Details", new { id = item.Description }) | 
      @Html.ActionLink("Delete", "Delete", new { id = item.status }) 
     </td> 
    </tr> 
    } 
</table> 

請任何一個可以告訴我怎麼寫這個代碼在MVC3

+0

@jimtollan我這樣做了,我在<%@ Page Title =「」Language =「C#」中創建一個錯誤MasterPageFile =「〜/ Views/Shared/SiteMaster.Master」Inherits =「System.Web.Mvc。 ViewPage >「%>說無效expressionterm foreach .. – SoftwareNerd 2012-07-13 08:02:23

回答

1

阿尼爾的ASPX,

它竊聽我,你發現這個這麼難做到,我不得不回來給你如何做到這一點的基礎細節自己(授人以漁等.. :-))。無論如何,從頂部,做正常的東西是aspx頁面有,你的情況:

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" 
Inherits="System.Web.Mvc.ViewPage<IEnumerable<Gridview_BugTracker.Models.BugTracker_DataHelper>>" %> 

OK,現在到樣品塊:

剃刀:

@foreach (var item in Model) 

的aspx:

<% foreach (var item in Model) { %> 
    //... stuff 
    <%: Html.DisplayFor(modelItem => item.Description) %> 
    // more stuff 
    <%: Html.ActionLink("Edit", "Edit", new { id = item.projectName }) %> | 
    <%: Html.ActionLink("Details", "Details", new { id = item.Description })%> | 
<% } %> 

正如你所看到的,純粹的語法變化需要真正應該不超過5分鐘。

祝你好運 - 我知道這是怎麼回事。