Introduction to asp.net MVC 3 beta new features

Source: Internet
Author: User
Keywords We like the next new features can face the
Tags .net added asp asp.net aspx change class code

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.