2011-01-07 3 views
1

데이터 입력을위한 웹 응용 프로그램을 만들었습니다 (데이터 유형은 중요하지 않습니다). 이 사이트의 한 부분으로 사용자는 동적으로 데이터 행을 추가 할 수 있습니다. 정적 입력 필드의 경우 DataAnnotations를 사용하여 필드의 유효성을 관리 할 수 ​​있습니다. 동적 필드에 대해 비슷한 작업을 시도 할 때 유효성 검사가 작동하지 않는 것 같습니다.동적 행 확인

다음은 내 응용 프로그램의 (일반) 설정입니다.

[Data Input Page] -> [Partial Page for Dynamic Table] -> [Table is made up of individual rows (partial page)] 

각 페이지는 강하게 입력됩니다. 여기

는 부분 페이지 개인 행의 예입니다 :

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

<tr> 
<% using (Html.BeginCollectionItem("People")) { %> 
    <td class="ui-widget-content"><%= Html.TextBoxFor(model => model.Name) %></td> 
    <td class="ui-widget-content"><%= Html.TextBoxFor(model => model.Age) %></td> 
    <td class="ui-widget-content"><%= Html.TextBoxFor(model => model.PhoneNumber) %> 

    // [Cut] Some other, unimportant information here which allows a new row to be added. 
</tr> 

// This portion is not working - it does work with static fields. 
<div class="validation"> 
    <div><%: Html.ValidationMessageFor(model => model.Name)%></div> 
    <div><%: Html.ValidationMessageFor(model => model.Age)%></div> 
    <div><%: Html.ValidationMessageFor(model => model.PhoneNumber)%></div> 
</div> 

(그래서 내가 이미 뭘하는지 유사/동일) 될 DataAnnotations와 함께 작동하도록 유효성 검사를 받고 어떤 통찰력 매우 감사.

답변

1

스티브 샌더슨 blogged about validation이 경우.

+0

감사합니다 (수락 됨). 그것은 질문에 답합니다. 그래도 미친 짓이야. – JasCav