Some new features in the coming ASP. NET MVC RC

Source: Internet
Author: User

Scott finally posted an article on his blog yesterday (this guy has a serious shortage of production capacity). I'm glad to see it, hope to help you.

  • This article is not purely translated;
  • Click here for the original article. ASP. net mvc design gallery and upcoming view improvements with the ASP. net mvc release candidate;
  • The level is limited. I hope you can understand what is unclear or wrong. Let's leave bricks to four socialist modernization projects.

I am still a view, but I finally get rid of the code-behind file!

This is not easy, and the code that is criticized is finally shot. After hearing a lot of feedback from the community, Microsoft decided to make this change to the view. By default, we will not see that the awkward. CS/. VB file will appear after the simple view. This change has killed a lot of useless post-code files (of course, the bigger the project is). More importantly, it enables the view to focus only on what it should do-rendering.

In fact, this is very embarrassing, but it should have been like this. (See the figure to find a clean solution)

In the current beta version, users can only use CLR generics to change the inherited attributes of the view to remove the post-code. However, if Microsoft doesn't talk about this method, it is hard to find it, and it is indeed a bit obscure... Now, in ASP. net mvc rc, we can directly use the C #/VB.net syntax to change the inherited attributes of the view.

 

Another benefit of not using code-behind is that when we add a View to the current project, we can get Intelligent Code awareness in the view immediately. In beta and earlier versions, we had to re-compile a view after adding it. (Some people often ask this question, "why don't I receive any helper prompts when I press HTML?", which is actually the reason ).

The view can use the top-level model property)

Viewdata. model is often used in the past.

Now we can do this directly.

The results are the same. The only benefit is that you do not have to enter eight letters or a dot.

The Lambda expression can be used in htmlhelper and ajaxhelper to communicate with the model.

In beta, since htmlhelper and ajaxhelper do not expose model type in their signatures, we have to use the <tModel> base class of viewpage to extend the communication between helper and model using lambda. However, this problem has been improved in the RC version. Microsoft exposed two new types in viewpage <tModel>: htmlhepler <tModel> and ajaxhelper <tModel>. From now on, we can build strong htmlhelper and ajaxhelper extension methods through lambda expressions during model communication.

Next is a simple example of a strong textbox helper provided by Scott.

Then you can directly use it in the view, and this means that it will also be supported by vs's code intelligence awareness.

Others

The article also mentions many new improvements in RC, for example, idataerrorinfo, the new fileresult and javascriptresult actionresult types, built-in jquery smart sensing support, improved scalability, and bug fixes that are not known to everyone.

There are also some content that will increase production at a time. If you are interested, you can find it in his blog. The link is shown above.

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.