The return of National Day holiday, just in time to catch up with asp.net MVC 3 beta release, and you share some of my experience.
The first is the change in the selection interface when creating the project:
1.View engine changes.
Razor This view engine is added to ASP.net mvc 3.
If you have both index.aspx and index.cshtml in the project you created, the default MVC will select the ASPX view to display. But you can add the following code to the Application_Start method in the Global.asax file to let MVC execute the index.cshtml page of Razor engine first.
The code is as follows:
ViewEngines.Engines.Clear ();
VIEWENGINES.ENGINES.ADD (New Razorviewengine ());
VIEWENGINES.ENGINES.ADD (New Webformviewengine ()); 2. You can modify the order of the attribute display in model
In previous versions, if we created the following model:
public class Employee
{
public string FirstName {get; set;}
public string LastName {get; set;}
public int EmployeeId {get; set;}
}
Create a view code for this model as follows:
<%@ 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>
After running, you can see that the attribute fields for the employee class are displayed as follows:
In asp.net mvc 3, we can flexibly modify the placement of fields on the view page by setting the order in which the properties are displayed, for example:
Run the program again, the employee's display is as follows:
3. New Grid Control added
We use the above employee to create a grid:
To display the code for the Controller section:
View section, we use the WebGrid in the System.Web.Helpers class to display several employee information above.
Run, the results are as follows:
We set the ' FirstName ' to sort. You can change the sort by clicking on the header of the other column.
4. New chart components are added.
We're going to create a column chart of Employee sales performance in relation to employee and sales.
We create a model for Employeesale
The controller section adds a Showchart control:
Finally, the View section:
Note here that the chart control is displayed by creating a temporary PNG image that does not save the PNG image on the server side after the page access is complete.
Operation Effect:
For more new features please refer to release notes. The follow-up will continue to introduce other features, such as the IOC.
Code download