Recently, I suddenly found that mvc3 contains a lot of content that I have not used flexibly. Unfortunately, in the previous article, I wrote two classes and view views to implement paging, however, I have read the advantages of mvc3, and I prefer mvc3.
1. Razor view Engine
I have to say that the razor view engine is so cool that I like its refreshingCodeStyle, which uses the @ symbol to represent the code block. The following code is valid in razor:
Reference content is as follows:
@ Foreach (VAR item in Model ){
<B> @ item. fullname </B>
}
2. New assistant
The assistant has always been a disadvantage of ASP. net mvc compared with other MVC frameworks. ASP. net mvc 3 provides new assistants, which will narrow the gap between this field and competitors.
Chart: helps create charts, which are very easy to use.
Webgrid: displays object sets in a grid, including paging and sorting functions. It can be output as a common HTML table.
Webimage: helps you create images, including basic image operation methods, such as rotation, amplification, and reduction.
Webmail: used to send emails.
The next-generation assistant is called the "Task-Based assistant". It was originally included in the test version, but now it is invisible. I hope to see it in the final official version, because it is so fascinating to me.
Video: includes video. Flash, video. Silverlight, and video. mediaplayer. You can add HTML tags for these methods.
Twitter: contains basic Twitter operations, such as presenting a Twitter stream of a specific user or a given search result.
Recapcha: helps you use the reCAPTCHA service.
Gravatar: Specifies a user profile from the gravatar service.
Analytics: provides different methods for different analysis services, such as getgooglehtml, getstatcounterhtml or getyahoohtml, and provides the required JavaScript code.
3. Support for jquery-based Ajax
In ASP. net MVC 3, Ajax. actionlink, Ajax. routelink, Ajax. beginform and Ajax. beginrouteform will use jquery to connect to the server. In addition, they will not use inline JavaScript, they will call the functions provided in the Javascript file, and client verification is similar to this.
4. Support for New dependency injection to improve scalability
ASP. net mvc 3 will contain a large number of extensions, and almost everything can be extended using dependency injection.
5. Integrate nupack
Nupack is a new packaging system of Microsoft. It is completely compatible with ASP. net MVC 3 is integrated, right-click the "Reference" folder in Solution Explorer, and select "add package reference", as shown in.
Figure 1 Add a package reference
The nupack interface is displayed, where you can select different libraries, as shown in.
Figure 2 nupack add package reference page
Bytes ------------------------------------------------------------------------------------
Knowledge is the main practice of leading street lights!
Use webgrid for paging:
Control:
Public actionresult webgrid ()
{
// Obtain data
Mercurydbexentities DB = new mercurydbexentities ();
VaR result = dB. Users. tolist ();
Viewdata. Model = result;
Return view ();
}
View:
@ Using mvc3_test.database
@ Model ienumerable <mvc3_test.database.users>
@{
Viewbag. Title = "webgrid ";
Layout = "~ /Views/shared/_ layout. cshtml ";
}
<H2> webgrid </H2>
@{
VaR grid = new webgrid (Source: model,
Fieldnameprefix: "Grid _",
Defaultsort: "ID ",
Canpage: True,
Cansort: True,
Ajaxupdatecontainerid: "divgrid ",
Pagefieldname: "Paging ",
Sortfieldname: "soutfield ",
Rowsperpage: 10 );
}
<Div id = "divgrid">
@ Grid. gethtml (
Columns: grid. Columns (
Grid. Column ("ID", "ID "),
Grid. Column ("loginname", "loginname ")
)
)
</Div>
The page is complete.