Features of .NET Framework 4.0
Below are some of the new features that .net framework 4.0 provides from development point of view.
1. Better Viewstate management: When we use viewstate to store large amount of data, it causes heavy performance penalty. To tackle this problem ASP.NET 4 introduces a new property called ViewStateMode in the Web controls with the help of which you can disable view state by default and then enable it only for the controls that require it in the page. This property has three values: Enable, Disable, and Inherit.
You can also set the ViewStateMode at the page level:
<%@ Page Title="MyPage" Language="C#" MasterPageFile="~/Site.master"
AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_OutputCacheDemo._Default" ViewStateMode="Disabled" %>
2. Session State Management: People generally store objects in session state during web application development. As you know the objects stored in the session state must be serializable, if object is heavy the size of serialized data becomes quite large. To solve this issue ASP.NET 4 introduces a new compression option for both kinds of out-of-process session-state management techniques. When the compressionEnabled configuration option is set to true, ASP.NET will compress (and decompress) serialized session state by using the .NET Framework System.IO.Compression.GZipStream class.
<sessionState mode="SQLServer" sqlConnectionString="data source=dbservername;
Initial Catalog=aspnetstate" allowCustomSqlDatabase="true" compressionEnabled="true"/>
We generally get the Client id's for earlier version as below:
var mybtn = document.getElementById ("<% =Button1.ClientID %>");
ASP.NET 4 introduces new ClientIDMode property that specifies how the client ID is generated for controls. You can set the ClientIDMode property for any control, including for the page. Possible settings are the following:
• AutoID. This is equivalent to the earlier generated ClientId property values(Previous version of asp.net)
• Static. This specifies that the ClientID value will be the same as the ID without concatenating the IDs of parent naming containers.
• Predictable. This option is useful in data control that uses repeating templates. It concatenates the ID properties of the control's naming containers, but generated ClientID values do not contain strings like "ctlxxx". This setting works in conjunction with the ClientIDRowSuffix property of the control. You set the ClientIDRowSuffix property to the name of a data field, and the value of that field is used as the suffix for the generated ClientID value. Typically you would use the primary key of a data record as the ClientIDRowSuffix value.
• Inherit. This setting is the default behavior for controls; it specifies that a control's ID generation is the same as its parent.