In the MVC pattern, it is usually the controller process the request and generate the data, selecting a suitable view to display the results to the user. Although ASP.net mvc already has a very rich actionresult to meet the needs of different situations, with the sharp edge of Ajax, we want to have a smoother way of interacting. We want to be able to complete the display of the list in one interface, edit or add it, and complete the refresh. With the help of a jquery extension thickbox we can achieve this effect.
This article is inspired by a blog post: MVC AJAX Form with Ajax.beginform () and JQuery Thickbox (http://geekswithblogs.net/michelotti/archive/ 2009/08/31/mvc-ajax-form-with-ajax.beginform-and-jquery-thickbox.aspx)
And the difference is that in Thickbox, he updates the content in Thickbox instead of loading the Thickbox page (that is, the page behind Thickbox).
I show you the following scenario
Click "New Role" ① to pop up a new role thickbox input window ②, fill in the appropriate information, will use AJAX update role list ③.
Suppose you already know asp.net mvc very well.
Here we do not discuss the model layer in MVC, assuming model data can be obtained through the service layer.
In this case, we need 3 View:rolelist.aspx,rolenamelist.ascx and rolecreate.ascx. The latter two Partialview.
Rolecontroller needs to process the following several requests:
[Get] Rolenamelist (): Displays the role list and returns Rolenamelist.ascx this Partialview.
[Get] Rolecreate (): Displays the input interface of Create Rolecreate.ascx waits for user input related information.
[post] Relecreate: Handles the commit of the Create and returns ROLENAMELIST.ASCX.