-1

嗨,伙计们,我有一个剃须刀文件 Index.cshtml 需要转换为 aspx ......谁能帮助我如何声明类并将 .cshtml 中的所有内容建模为 .aspx

这是我的Index.cshtml代码

索引.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的aspx中编写这段代码

4

1 回答 1

1

阿尼尔,

它困扰着我,你发现这很难做到,我不得不回来告诉你如何自己做的基本细节(教一个人钓鱼等.. :-))。无论如何,在您的情况下,从顶部开始,执行 aspx 页面所具有的 NORMAL 内容:

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

好的,现在进入示例块:

剃刀:

@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 分钟。

祝你好运——让我知道结果如何。

于 2012-07-13T08:07:47.200 回答