自坑實錄 - Asp.net MVC中無法使用@Ajax.BeginForm問題解決

來源:互聯網
上載者:User

標籤:csdn   sdn   one   節點   pps   jquery   ati   down   enabled   

建立空的web項目,通過Nuget引用mvc組件來搭建空的MVC項目時,

在視圖頁面中無法使用@Ajax.BegForm來進行非同步提交資料,

而建立預設的MVC模板項目卻能夠正常使用@Ajax.BegForm,

所有的引用都是齊全的,那麼問題出在哪裡呢?

.....................<script src="~/Scripts/jquery.min.js"></script><script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>.....................

 

沒錯,在全域的Web.config設定檔中,需要在 <appSettings>......</appSettings>節點中添加如下配置:

<!-- 啟用unobtrusive校正外掛程式 --><add key="UnobtrusiveJavaScriptEnabled" value="true" />

 

配置完成後即可使用 @Ajax.BegForm 功能

 

補充: 

  若想使用 jquery.validate 組件,需要在視圖頁中引用:

<script src="~/Scripts/jquery.validate.min.js"></script><script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

    並且同樣需要在 <appSettings>......</appSettings>節點中添加配置:

<!-- 啟用用戶端validate校正外掛程式 --><add key="ClientValidationEnabled" value="true" />

 

    同時需要注意的是,jquery.js/jquery.min.js 必須最先引入(因為其它 js庫依賴於jquery)

 

使用到的庫:   http://download.csdn.net/detail/qq_30964095/9813775

 

自坑實錄 - Asp.net MVC中無法使用@Ajax.BeginForm問題解決

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.