2010-04-30 2 views
1

에는 활성 공백을 생성하는 동작이 있습니다. 코드는 아래와 같습니다.렌더링 부분 또는 렌더링

공개 ViewResult OpenVacancies() { var openvacancies = db.GetActiveVacancies(); 돌아 가기보기 (openvacancies); }

여러 페이지에서이 목록을 사용하고 싶습니다. 사용하는 가장 좋은 방법은 html.renderaction (제발 여기 잘못 생각하십시오)입니다.

보기 및 .ascx 컨트롤은 영역에 있습니다.

그런 다음 작업 내부를 마우스 오른쪽 버튼으로 클릭하고 .ascx 및 공석 유형에 대한 강력한 입력보기를 작성하여보기를 만들었습니다. 나는 "List"의보기 내용을 선택했다.

그런 다음이 줄을 필요한 페이지에 추가했습니다.

보기 및 .ascx 컨트롤은 영역에 있습니다.

내가 가진 오류는 다음과 같습니다.

형식 또는 네임 스페이스 이름 '공석이'을 (를) 찾을 수 없습니다 (당신은 using 지시문 또는 어셈블리 참조가?)

가의 .ascx 코드는 다음과 같습니다;

> "%>
<table> 
    <tr> 
     <th></th> 
     <th> 
      VacancyID 
     </th> 
     <th> 
      JobTitle 
     </th> 
     <th> 
      PositionID 
     </th> 
     <th> 
      LocationID 
     </th> 
     <th> 
      JobDescription 
     </th> 
     <th> 
      JobConditions 
     </th> 
     <th> 
      Qualifications 
     </th> 
     <th> 
      RequiredSkills 
     </th> 
     <th> 
      Certifications 
     </th> 
     <th> 
      AdvertDate 
     </th> 
     <th> 
      AdvertExpiryDate 
     </th> 
     <th> 
      Status 
     </th> 
     <th> 
      StaffLevel 
     </th> 
     <th> 
      LineManagerEmail 
     </th> 
     <th> 
      ApprovalFlag 
     </th> 
     <th> 
      RequisitionDate 
     </th> 
    </tr> 

<% foreach (var item in Model) { %> 

    <tr> 
     <td> 
      <%= Html.ActionLink("Edit", "Edit", new { id=item.VacancyID }) %> | 
      <%= Html.ActionLink("Details", "Details", new { id=item.VacancyID })%> | 
      <%= Html.ActionLink("Delete", "Delete", new { id=item.VacancyID })%> 
     </td> 
     <td> 
      <%= Html.Encode(item.VacancyID) %> 
     </td> 
     <td> 
      <%= Html.Encode(item.JobTitle) %> 
     </td> 
     <td> 
      <%= Html.Encode(item.PositionID) %> 
     </td> 
     <td> 
      <%= Html.Encode(item.LocationID) %> 
     </td> 
     <td> 
      <%= Html.Encode(item.JobDescription) %> 
     </td> 
     <td> 
      <%= Html.Encode(item.JobConditions) %> 
     </td> 
     <td> 
      <%= Html.Encode(item.Qualifications) %> 
     </td> 
     <td> 
      <%= Html.Encode(item.RequiredSkills) %> 
     </td> 
     <td> 
      <%= Html.Encode(item.Certifications) %> 
     </td> 
     <td> 
      <%= Html.Encode(String.Format("{0:g}", item.AdvertDate)) %> 
     </td> 
     <td> 
      <%= Html.Encode(String.Format("{0:g}", item.AdvertExpiryDate)) %> 
     </td> 
     <td> 
      <%= Html.Encode(item.Status) %> 
     </td> 
     <td> 
      <%= Html.Encode(item.StaffLevel) %> 
     </td> 
     <td> 
      <%= Html.Encode(item.LineManagerEmail) %> 
     </td> 
     <td> 
      <%= Html.Encode(item.ApprovalFlag) %> 
     </td> 
     <td> 
      <%= Html.Encode(String.Format("{0:g}", item.RequisitionDate)) %> 
     </td> 
    </tr> 

<% } %> 

</table> 

<p> 
    <%= Html.ActionLink("Create New", "Create") %> 
</p> 

답변

0

첫째, 당신은 단순히 여러 페이지에보기를 다시 사용하려는 경우, 당신은 <퍼센트 Html.RenderPartial와 공유 부분보기 (공유 폴더에 넣습니다)를 사용한다 (.. "OpenVacancies");이 뭔가를 원할 것입니다 %>

둘째, 당신의 코드를 기반으로, 당신의 부분보기 강하게

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> 

하는 대신 입력 할 수 표시되지 않습니다

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Vacancy>>" %> 
+0

안녕 james..i이 일을하고 기쁨을 얻지 못했습니다 .. – femi