1

有人可以帮忙吗,不知道我做错了什么:

我的视图模型:

public class ScormModuleViewModel
{
  public IEnumerable<ScormModuleInfo> ScormModuleInfo { get; set; }
  public int CurrentPage { get; set; }
  public int PageSize { get; set; }
  public double Total { get; set; }
  public int RecordsPerPage { get; set; }
}

然后我的控制器:

public ActionResult Index(int? page)
{
  List<ScormModuleInfo> modules = new List<ScormModuleInfo>();
  foreach (var directory in Directory.EnumerateDirectories(scormRootDir))
  {
     ScormModuleInfo module = new ScormModuleInfo();
     module.ScormModule = ZincService.ScormService.GetScormModule(scormTitle, scormDirectory);

      if (module.ScormModule != null)
        module.Installed = true;
      else
      {
        module.Installed = false;
        module.ScormModule = new ScormModule();
        module.ScormModule.Directory = scormDirectory;
        module.ScormModule.Title = scormTitle;
      }

      module.ScormModule.EntryPointRef = scormEntryPointRef;
      module.ScormModule.IdentifierRef = scormIdentifierRef;
      module.ScormModule.LaunchHeight = scormLaunchHeight;
      module.ScormModule.LaunchWidth = scormLaunchWidth;
      module.ScormModule.LaunchResize = scormLaunchResize;
      module.ScormModule.RelativeHtmlPath = scormRelativeHtmlPath;
      module.ScormModule.SchemaVersion = scormSchemaVersion;

      if (module.Installed)
      {
        // TODO: Save changes to module
        //ZincService.ScormService.UpdateScormModuleSettings(
      }

      modules.Add(module);
      noOfScormPackages++ ;

    }
  }

  ScormModuleViewModel model = new ScormModuleViewModel();
  model.ScormModuleInfo = modules;
  model.CurrentPage = page.GetValueOrDefault(1);
  model.PageSize = PageSizeSettings.ScormPackages;
  model.Total = noOfScormPackages;

  // Now iterate over modules and read imsmanifest.xml file for details of entry point and resources required.

  return View(model);
 }

和我的观点:

 <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<List<Zinc.Web.Areas.Admin.ViewModels.Scorm.ScormModuleViewModel>>" %>

      foreach (var module in Model)
   { %>
 <li>
   <div class="col1">
     <a href='javascript:LoadTrainingModuleWithDedicatedAPIObj("<%= module.ScormModuleInfo.r   .sc.ScormModule.RelativeHtmlPath %>/<%= module.ScormModule.EntryPointRef %>", "<%: module.ScormModule.Title %>", "<%: module.ScormModule.LaunchWidth %>", "<%: module.ScormModule.LaunchHeight %>");'>
       <% if (module.ScormModule.Title.Length < 70)
          { %>
         <%: module.ScormModule.Title%>
       <% }
          else
          { %>
          <%: module.ScormModule.Title.Substring(0, 70)%>....
       <% } %>
     </a>
   </div>

我在所有模块下都得到了红线。特性?我不明白,我做错了什么?谢谢

4

1 回答 1

0

Model是你的视图模型。Model.ScormModuleInfoScormModuleInfo类型的 IEnumerable。

foreach (var module in Model.ScormModuleInfo)

在您的控制器中,您传递ScormModuleViewModel给查看不是List<ScormModuleViewModel>

所以替换

System.Web.Mvc.ViewPage<List<Zinc.Web.Areas.Admin.ViewModels.Scorm.ScormModuleViewModel>>

至:

System.Web.Mvc.ViewPage<Zinc.Web.Areas.Admin.ViewModels.Scorm.ScormModuleViewModel>
于 2013-03-08T07:58:24.957 回答