Queries are an essential part of the project, and different teams of different projects have their own simple methods. asp.net MVC has its own unique advantages, and here is a demo that combines MVC to achieve a product list.
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:
How does an MVC asynchronous query asp.net?
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 select the filter criteria, click 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>
}
I hope this article will help you, asp.net How to do MVC asynchronous query content is introduced here. Hope you continue to pay attention to our website! Want to learn asp.net can continue to focus on this site.