2010-07-09 3 views
0

부분 뷰 (아래)가있는 MVC 앱이 있습니다. Html.EnableClientValidation()을 추가하면 필드가 종료 될 때 필드가 사라집니다. 누구든지 코드에서 알아낼 것으로 기대하지는 않습니다.하지만 누군가가 그러한 행동을 보았고 올바른 방향으로 나를 가리킬 수 있다면, 고맙겠습니다. 그 동안 나는 한 장씩 재건을 시작하고 내가 볼 수있는 것을보고 다시보고 할 것이다.EnableClientValidation으로 인해 필드가 사라집니다.

감사합니다.

<%= Html.ValidationSummary() %> 
<% Html.EnableClientValidation(); // IMPORTANT: this line MUST be *before* Html.BeginForm() block %> 
<% using (Ajax.BeginForm("Save", "Items", new AjaxOptions { HttpMethod = "post", InsertionMode = InsertionMode.Replace, UpdateTargetId = "ItemPane"})){%> 
<%=Html.AntiForgeryToken()%> 
<%=Html.Hidden("Item.Id", (ViewData.Model.Item != null) ? ViewData.Model.Item.Id : Guid.Empty)%> 
<!--more hidden items elided--> 
    <table> <!--yes, I know it should be divs--> 
     <tr> 
      <td rowspan="2" width="400px"> 
      <div class="formarea"> 
      <fieldset> 
       <ol> 
        <li> 
         <label id="Item_Label"><%= (ViewData.Model != null && ViewData.Model.Item != null) ? String.Format("Item Number {0} v. {1}", ViewData.Model.Item.ItemNumber, ViewData.Model.Item.Iteration) : "New Item" %></label> 
        </li> 
        <li> 
         <label for="Item_Prompt" class="formLabel">Directions:</label> 
         <%=Html.TextAreaFor(t => t.Item.Directions, 3, 50, new { @class = "text2000", @maxlength = "2000" })%> 
         <%= Html.ValidationMessageFor(t => t.Item.Directions, "*")%> 
        </li> 
        <li> 
         <label for="Item_Prompt" class="formLabel">Prompt:</label> 
         <%= Html.TextBoxFor(model => model.Item.Prompt, new { @class = "text200", @maxlength = "200" })%> 
         <%= Html.ValidationMessageFor(model => model.Item.Prompt, "*")%> 

        </li> 

I가 다음 스크립트 참조 :

<%= Html.Script("~/Scripts/MicrosoftAjax.debug.js") %> 
<%= Html.Script("~/Scripts/MicrosoftMvcAjax.debug.js") %> 
<%= Html.Script("~/Scripts/jquery-1.4.2.min.js") %> 
<%= Html.Script("~/Scripts/jquery-ui-1.8.2.custom.min.js") %> 
<%= Html.Script("~/Scripts/jquery.form.js") %> 
<%= Html.Script("~/Scripts/MicrosoftMvcValidation.js") %> 
+0

참고 바랍니다 문제가 해결됩니다 : 이것은 Html.BeginForm() 또는 Ajax.BeginForm를 사용하는지 여부 일() – sydneyos

답변

0

는 그것을 알아 냈다 - 그것은 this code으로 이전 희롱에서이 CSS를했다 :

/------ -------------------------------------------------- - ASP.NET MVC 프레임 워크 DEFAULT CSS 클래스 이름 ------------------------------------- ---------- -----------/ . 오류, .field 유효성 검사 오류 {color : red}

.input-validation-valid, .field-validation-valid, .validation-summary -valid {display : none} . 입력 유효성 검사 오류 {background-color : #fee; 테두리 : 1px 빨강 빨강; 입력 유효성 검사 오류 : focus, select.input 유효성 검사 오류 : focus {outline : none} .input 유효성 검사 오류 : focus {outline : none} 입력 [

.validation - 요약 - 오류 {색상 : 빨강} : .validation - 요약 - 오류 UL {목록 스타일 : 내부 디스크} .validation - 요약 - 오류는 {700 글꼴 무게를}에 걸쳐 .validation- summary-errors ul li {font-weight : normal} 유효성 검사 요약 오류 ul li 레이블, 유효성 확인 요약 오류 ul li span {표시 : 인라인! 중요; font-weight : normal}

0

같은 문제가있었습니다.

textboxfor와 유효성 확인 메시지를 두 개의 다른 div로 구분하면됩니다.

문제는 필드가 사라지는 이유 때문에 부모를 제거하는 확인 메시지가 있다는 것입니다. 이전 div에 액세스 할 수없는 두 가지 간단한 div 유효성 확인 메시지가 있습니다.

이 내가

관련 문제