TechBubbles Microsoft Technology BLOG

ASP.NET Web Forms 4.5 new features in Visual Studio 2012

This post discuss ASP.NET Web Forms 4.5 features, Web Forms in 4.5 allows you to build dynamic web sites quickly and easily. Web Forms generates much cleaner code on client-side with Unobtrusive Validation in this version. You can also build data-centric applications easily with data-binding features. image

Typical Web Form which contains more fields and validation controls can generate more code on client-side. When you run this typical form in browser then you can see the page size as below

image

The reason for this size is because client-side validation is enabled. If you change Unobtrusive validation mode in page load to web forms then you can see the difference.

image

Now re-compile your application and run the page the result is as shown below, Now page size is much smaller than before

image

Strongly typed Data Controls

Take a typical Search Form which shows the results in list view. Inside list view you have item template which is having multiple calls to the EVAL expression as shown below

image

The above method is the standard way of doing data-binding in web forms. You optimize the above using strongly typed data controls.

You can set the Item Type property of List View to the type that you actually data-binding to as shown below

image

Now you can member variables in place of Eval expressions, member variables are now typed and you will get an intellisense on item class.

image

Model Binding

You may be familiar with Model Binding in ASP.NET MVC, The typical code which you might write in web forms to bind the results in web forms as below

image

The above code talking to the data base by building a query which does a case insensitive search then it coverts into list binds the results to list view. Let us re-write the above code using Model-Binding

image

Now there is no page load and click-handler, The above code is not directly interacting with the page. You can populate the formTerm and qsTerm variables using attributes Control and QueryString in model-binding.

The return result of GetResults method is IQueryable. Because the result is of type IQueryable the control has the ability to modify this before it is rendering it to the page. You can use this in sorting and paging. You can specify the same in markup.

Advantage of using Model Binding As the code is not directly interacting with the page, you can fairly easily unit test the method or even move it to the completely different class.

Support for OpenID in OAuth Logins

image

The AuthConfig.cs file is standard in all new projects that created in ASP.NET 4.5 in Visual Studio 2012. You can see there are number of external services code is commented out and it is ready to use by putting your custom application credentials.

Now you can use external services to login to the application.

image

These are the features which you can try out in Visual Studio 2012.

Reference: Damian Edwards talk in Visual Studio launch.


Share this post :

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

2 Comments

  • .Net 4.5 cannot install in Windows XP, Windows 2003.

    Itanium processors are not supported.

    You can store more than 2 GB data in arrays.

    workstation garbage collection overhead issues is solved using Server GC

    You set Timeout for Regular expressions.

    In Windows 8, it uses Unicode 6.0.0

By Kalyan Bandarupalli
TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud