oa_mvc_easyui_登入完成(2)

來源:互聯網
上載者:User

標籤:非同步   control   attr   inf   表單   options   jquery   login   route   

1.使用MVC特有的ajax方式:非同步表單提交方式

  js檔案引用:<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>

  代碼:

 @using(Ajax.BeginForm("UserLogin",new{},new AjaxOptions(){OnSuccess="afterLogin"},new{id="loginForm"})){
......
//相關的表單
}

**

使用Ajax.BeginForm方法會產生一個form表單,最後以Ajax的方式提交表單資料;需要用using把該方法括起來,使系統知道form表單從何處開始,何處結束。

 new AjaxOptions(){...} -- ajax的一些參數

 new {id="loginForm"} -- htmlAttributes,html屬性,產生form表單時,會把索引值對添加到form表單的屬性中

 new{} -- routeValues...

 "CheckLogin" -- 指定請求地址的Action名稱

參考:http://www.cnblogs.com/zzgblog/p/5454019.html?_t=t

        http://www.cnblogs.com/haof3344/p/4659040.html

 

2. 控制器LoginController中編寫登入的方法:UserLogin(),用於非同步ajax重新整理

 

oa_mvc_easyui_登入完成(2)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.