이상한 일이 내 ASP.NET MVC 3 앱 중 하나에서 계속 발생합니다.유효성 검사 속성없이 부분 뷰가 표시됨 (ASP.NET MVC 3)
jQuery Ajax API를 통해 삽입 행을 가져 오는 중이므로 아무런 문제가 없습니다. 그러나 필요한 부분 뷰를 다시 얻었을 때 유효성 검사 속성없이오고 있으며 해당 행에 대한 유효성을 다시 바인딩 할 수 없습니다. 여기
내가 아약스 응답으로 무엇을 얻을 수 있습니다 :
여기<input type="hidden" name="accommPropertyPeriods.index" autocomplete="off" value="ccaa15b3-76f1-4215-8bb5-a62d700bfc1e" />
<table style="width:100%;">
<tr>
<td>
<div class="editor-field">
<select class="chzn-select-deselect" data-placeholder="Choose an Alias..." id="accommPropertyPeriods_ccaa15b3-76f1-4215-8bb5-a62d700bfc1e__AccommPropertySeasonPeriodAliasID" name="accommPropertyPeriods[ccaa15b3-76f1-4215-8bb5-a62d700bfc1e].AccommPropertySeasonPeriodAliasID" style="min-width:100px;"><option value="302">A</option>
<option value="303">B</option>
<option value="304">C</option>
<option value="305">D</option>
</select>
</div>
</td>
<td>
<div class="editor-field">
<input class="datefield" id="accommPropertyPeriods_ccaa15b3-76f1-4215-8bb5-a62d700bfc1e__PeriodStartsAt" name="accommPropertyPeriods[ccaa15b3-76f1-4215-8bb5-a62d700bfc1e].PeriodStartsAt" type="text" value="" />
</div>
</td>
<td>
<div class="editor-field">
<input class="datefield" id="accommPropertyPeriods_ccaa15b3-76f1-4215-8bb5-a62d700bfc1e__PeriodEndsAt" name="accommPropertyPeriods[ccaa15b3-76f1-4215-8bb5-a62d700bfc1e].PeriodEndsAt" type="text" value="" />
</div>
</td>
</tr>
</table>
내가 점점해야 무엇 :
<input type="hidden" name="accommPropertyPeriods.index" autocomplete="off" value="84ddd0f5-a3e2-4f10-8e67-f32528c6393d" />
<table style="width:100%;">
<tr>
<td>
<div class="editor-field">
<select class="chzn-select-deselect" data-placeholder="Choose an Alias..." data-val="true" data-val-number="The field AccommPropertySeasonPeriodAliasID must be a number." data-val-required="The AccommPropertySeasonPeriodAliasID field is required." id="accommPropertyPeriods_84ddd0f5-a3e2-4f10-8e67-f32528c6393d__AccommPropertySeasonPeriodAliasID" name="accommPropertyPeriods[84ddd0f5-a3e2-4f10-8e67-f32528c6393d].AccommPropertySeasonPeriodAliasID" style="min-width:100px;"><option value="302">A</option>
<option value="303">B</option>
<option value="304">C</option>
<option value="305">D</option>
</select>
<span class="field-validation-valid" data-valmsg-for="accommPropertyPeriods[84ddd0f5-a3e2-4f10-8e67-f32528c6393d].AccommPropertySeasonPeriodAliasID" data-valmsg-replace="false">*</span>
</div>
</td>
<td>
<div class="editor-field">
<input class="datefield" data-val="true" data-val-required="The PeriodStartsAt field is required." id="accommPropertyPeriods_84ddd0f5-a3e2-4f10-8e67-f32528c6393d__PeriodStartsAt" name="accommPropertyPeriods[84ddd0f5-a3e2-4f10-8e67-f32528c6393d].PeriodStartsAt" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="accommPropertyPeriods[84ddd0f5-a3e2-4f10-8e67-f32528c6393d].PeriodEndsAt" data-valmsg-replace="false">*</span>
</div>
</td>
<td>
<div class="editor-field">
<input class="datefield" data-val="true" data-val-required="The PeriodEndsAt field is required." id="accommPropertyPeriods_84ddd0f5-a3e2-4f10-8e67-f32528c6393d__PeriodEndsAt" name="accommPropertyPeriods[84ddd0f5-a3e2-4f10-8e67-f32528c6393d].PeriodEndsAt" type="text" value="" />
<span class="field-validation-valid" data-valmsg-for="accommPropertyPeriods[84ddd0f5-a3e2-4f10-8e67-f32528c6393d].PeriodEndsAt" data-valmsg-replace="false">*</span>
</div>
</td>
</tr>
</table>
의 GUID가 동일 할 필요는 없습니다. 나는 이른바 비 순차적 바인딩을하고있다.
[HttpPost] public PartialViewResult accommPropertySeasonPeriodCreatePartialView(int id, int subid) { //some other stuff going on here. non-related to partial view. return PartialView("_AccommPropertySeasonPeriodCreatePartialView"); }
나는 거의 내 마음의 생각이 일어나는 이유를 알아낼 :
여기에 나는 새로운 삽입 행을 얻을 JQuery와 아약스를 호출하고있는 작업입니다. 어떤 생각?
아, 문제가 될 것입니다. 이미 기본보기에 양식이 있습니다. 자동으로이 문제를 해결할 수있는 다른 방법이나 편집기 템플릿을 무시해야합니까? – tugberk
@tugberk, 부분적으로 FormContext를 수동으로 인스턴스화하는 것에 대한 내 업데이트를 참조하십시오. –
굉장! 완전히 일했다. 단지 그것을 이해하기 위해이 팅겨보고가 프레임 워크 (또는 템플릿 엔진?)에 입력 필드의 데이터 유효성 검사 속성을 전달하는 것을 이해하도록 정확히 알려줍니다. – tugberk