Links: http://www.cnblogs.com/n-pei/archive/2010/10/11/1848089.html
After the National Day holiday, I just caught up with Asp.net MVC 3 beta release and shared my experience with you.
The first step is to change the selection interface when creating a project:
1. View engine changes.
The view engine razor is added to Asp.net MVC 3.
If index. aspx and index. cshtml are the same in the created Project, the default MVC view is Aspx. However, you can add the following to the application_start method in the global. asax file:CodeTo let MVC first execute the index. cshtml page of razor engine.
The Code is as follows:
Viewengines. Engines. Clear ();
Viewengines. Engines. Add (New razorviewengine ());
Viewengines. Engines. Add (New webformviewengine ());
2. You can modify the attribute display sequence in the model at will.
In previous versions, if we create a model as follows:
Public class employee
{
Public String firstname {Get; set ;}
Public String lastname {Get; set ;}
Public int employeeid {Get; set ;}
}
The following code creates a view for this model:
<% @ Page title = "" Language = "C #" masterpagefile = "~ /Views/shared/site. Master"
Inherits = "system. Web. MVC. viewpage <mvc3beta. Models. Employee>" %>
<Asp: Content ID = "content1" contentplaceholderid = "titlecontent" runat = "server">
Employee details
</ASP: content>
<Asp: Content ID = "content2" contentplaceholderid = "maincontent" runat = "server">
<%: HTML. editorformodel (model) %>
</ASP: content>
After running, you can see that the attributes of the employee class are shown as follows:
In Asp.net MVC 3, we can set the display sequence of attributes to flexibly modify the positions of fields on the view page. For example:
Run againProgram, The display of employee is as follows:
3. Added the grid control.
We will use the above employee to create a grid:
Show the Controller code:
View section. We use the webgrid in the system. Web. helpers class to display the preceding information about the employees.
The result is as follows:
We set 'firstname' to sort. You can change the sorting by clicking the header of another column.
4. added the chart component.
Let's use the relationship between employee and sales to create a bar chart showing employee sales performance.
We create a model named employeesale.
Add a showchart control in the controller section:
Finally, View:
Note that the chart control is displayed by creating a temporary PNG image. After the page is accessed, the PNG image is not saved on the server.
Running effect:
For more new features, see release notes. Other functions, such as IOC,
Code download