Problem description
For some list pages, keep a consistent query code.
Solution
1, dependent documents Jquery.js, Jquery.unobtrusive-ajax.js.
2, create a partial view, Partialview main storage server sent over the data.
3, a ViewModel containing the collection data.
The partial view code is basically as follows:
Question Discussion
Of all the projects you've done, the entire page is divided into two parts. The above is a conditional filter, and the following is the result of the query. When I finish selecting the filter, click on the query, issue a POST request, and after the server responds, update the specified area
Information. And these, ASP.NETMVC can help us do, so we are the integration of MVC these functions can be.
1, Ajax. BeginForm
The area (Updatetargetid) that needs to be updated after the server response is supported. Similar to the AJAX control UpdatePanel in asp.net.
2. The partial view is used to display the changes in the client request.
For the query there are many ways to achieve this demo is also I do a number of interfaces before summing up, I believe there will be a better way out, I hope you share the code.
Benefits:
1, the code more concise, unified.
2, the server each send less data (for render the entire page).
Code:
@model ilist<demo.models.product>
@foreach (Demo.Models.Product item in Model)
{
<li class= "span3 tile tile-double @item. Color ">
<a href= "#" >
</a><span> @item. Name</span>
</li>
}