문제 : 보기에 추가 한 텍스트 상자를 종료 할 때 양식 제출 이벤트가 발생합니다.코드가 제거 된 후에도 this.form.submit()이 계속 실행됩니다.
Details : MVC 응용 프로그램에서 뷰 아래쪽에 세 개의 텍스트 상자를 추가했습니다. 이 페이지의 하단에 마지막으로 제어했다, 변경하기 전에
<%=Html.TextAreaFor(r => r.Notes, new { @class = "textAreaNoScroll", @onblur = "this.form.submit();"} })%>
이 또한 전에, 나는 그것을 밖으로 탭 때 this.form.submit을 발사하는 HTML 도우미 텍스트 영역을했다. 나는 코드 @onblur를 잘라 ... 그리고, 이제 마지막 제어 무엇인지, 그것을에 붙여 넣은 :
<%=Html.TextBoxFor(acc => acc.AccountNumber, new { @onblur = "this.form.submit();"}) %>
하지만 지금 디버깅 할 때 뷰는 여전히 아이디 'R와 텍스트 영역에 제출 않습니다 .노트'.
수정 : 먼저 브라우저 (Chrome)에서 '소스보기'에서 마크 업을 확인합니다. 변경 사항은 정확합니다. 브라우저 캐시를 지웠으나 별 차이가 없었습니다. 여기와 관계있는 코드 세그먼트는 다음과 같습니다
<asp:Panel ID="pnlProcessingInstructions" runat="server">
<table class="displayBox-topBottom">
<tr>
<td class="labels displayInput_noWidth">Processing Notes</td>
<td class="labels displayInput_noWidth">Instructions</td>
</tr>
<tr>
<%if (Model != null && Model.PaymentDayId != -1)
{ %>
<td><%=Html.TextAreaFor(r => r.ProcessingNotes, new { @class = "textAreaNoScroll" })%></td>
<%}
else
{%>
<td><%=Html.TextAreaFor(r => r.ProcessingNotes, new { @class = "textAreaNoScroll" })%></td>
<%}%>
<td><%=Html.TextAreaFor(r => r.Notes, new { @class = "textAreaNoScroll" })%></td> <!-- FORMER LAST CONTROL -->
</tr>
<tr>
<td><span id = "ProcessingCharsLeft" class="smallerFont">1,000</span> characters left</td>
<td><span id = "CharsLeft" class="smallerFont">1,000</span> characters left</td>
</tr>
</table>
</asp:Panel>
</fieldset>
<fieldset>
<legend class="labels"> Payment Details</legend>
<asp:Panel ID="pnlPaymentDetails" runat="server">
<table class="displayBox-topBottom">
<tr>
<td class="labels displayInput_noWidth">Institution</td>
<td class="labels displayInput_noWidth">Transit</td>
<td class="labels displayInput_noWidth">Account Number</td>
</tr>
<tr>
<td><%=Html.TextBoxFor(i => i.Institution) %></td>
<td><%=Html.TextBoxFor(tr => tr.TransitNumber) %></td>
<td><%=Html.TextBoxFor(acc => acc.AccountNumber, new { @onblur = "this.form.submit();"}) %></td> <!-- NEW LAST CONTROL -->
</tr>
</table>
</asp:Panel>
'this.form.submit가'여전히 컨트롤의 일부인 것처럼 결코 과거 'r.Notes'과 행위를 얻을 수 없습니다. 다시 말하지만 캐시를 지우고 내 솔루션을 다시 작성했습니다. 'this.form.submit()'이 코드가 존재하지 않는 컨트롤에서 어떻게 실행될 수 있습니까?
+1 문제를 발견 한 경우 답변을 게시하는 것이 좋습니다. – Sergio