Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 删除代码后,this.form.submit()仍会激发_Javascript_Html_Asp.net Mvc 3_Html Helper - Fatal编程技术网

Javascript 删除代码后,this.form.submit()仍会激发

Javascript 删除代码后,this.form.submit()仍会激发,javascript,html,asp.net-mvc-3,html-helper,Javascript,Html,Asp.net Mvc 3,Html Helper,问题: 我想做的是在退出已添加到视图的文本框时触发表单提交事件 详情: 我在MVC应用程序中有一个视图,在视图的底部添加了三个文本框。在此添加之前,我有一个Html helper textarea,当我从中弹出选项卡时,它触发了this.form.submit: <%=Html.TextAreaFor(r => r.Notes, new { @class = "textAreaNoScroll", @onblur = "this.form.submit();"} })%> r

问题: 我想做的是在退出已添加到视图的文本框时触发表单提交事件

详情: 我在MVC应用程序中有一个视图,在视图的底部添加了三个文本框。在此添加之前,我有一个Html helper textarea,当我从中弹出选项卡时,它触发了this.form.submit:

<%=Html.TextAreaFor(r => r.Notes, new { @class = "textAreaNoScroll", @onblur = "this.form.submit();"} })%>
r.Notes,新的{@class=“textareanoscorl”,@onblur=“this.form.submit();”}})%>
更改之前,这是页面底部的最后一个控件。我已经把代码@onblur剪掉了。。。并将其粘贴到,现在是什么,最后一个控件:

<%=Html.TextBoxFor(acc => acc.AccountNumber, new { @onblur = "this.form.submit();"}) %>
acc.AccountNumber,新的{@onblur=“this.form.submit();”})%>
但当我现在调试时,视图仍然在id为“r.Notes”的textarea上进行提交

修正: 首先,我从浏览器(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>  

处理票据
说明书
r、 ProcessingNotes,新的{@class=“textAreaNoScroll”})%>
r、 ProcessingNotes,新的{@class=“textAreaNoScroll”})%>
r、 注意,新的{@class=“textAreaNoScroll”})%>
还剩下1000个字符
还剩下1000个字符
付款详情
机构
换乘
帐号
i、 机构)%>
tr.TransitNumber)%%>
acc.AccountNumber,新的{@onblur=“this.form.submit();”})%%>

它永远不会超过“r.Notes”,就像“this.form.submit”仍然是控件的一部分一样。我再次清除了缓存并重建了解决方案。“this.form.submit()”如何在代码不存在的控件上触发

好吧,我想出来了。上一页正在使用相同的模型元素“r.Notes”。此页面具有form.submit事件,这是在我正在编辑的页面上触发提交的事件。我将textareafor重命名为html.textArea控件,并将其作为id重命名为MyNotes,但它不会提交。

+1如果发现问题,请发布答案。