Today I am giving you introduction for what’s new in asp.net 4.0.I hope this would help you.There are many enhancement made in asp.net 4.0
Setting Meta tag with Page
Asp.net 4.o added two new property like MetaKeyWords and MetaDescription. This property represents corresponding Meta tag in your Page
<head id="Head1" runat="server">
<title>My Page Title</title>
<meta name="keywords" content="Asp.net,Net,MVC,new' />
<meta name="description" content="My asp.net 4.o new feature article" />
</head>
Content of description metatag are use for search listing preview for google.
ViewStateMode Property (for Enable view state for individual control)
By default view state is enable for page, with the result each control of page are potentially store view state data in page so page size is increase that’s why performance is degrade. In earlier virsion developer can do that thing to disable view state but he want to disable for all control. Now in asp.net 4.0 new viewstatemode property introduce which take following enumerated data type like Enable, Disable, Inherit.
For disable viewstatemode for page set viewstatemode property is disabling then whatever control you need viewstatemode enable this property for that control.
See following example
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent" ViewStateMode="Disabled" >
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent" ViewStateMode="Disabled" >
<div>
No of item :
</div>
<div>
<asp:TextBox ID="txtNoitem" runat="server" onchange="intOnly(this)" onkeypress="showSaveCancel();intOnly(this);" onkeyup="intOnly(this)" />
</div>
<div id="divSaveCancel">
<asp:Button ID="btnSave" runat="server" Text=" Save " />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</div>
No of item :
See above example ViewStateMode is Desable so for all control
Changes to Browser Capabilities
ASP.NET determines the capabilities of the browser that a user is using to browse your site by using a feature called
browser capabilities. Browser capabilities are represented by the
HttpBrowserCapabilities object (exposed by the
Request.Browser property). For example, you can use the
HttpBrowserCapabilities object to determine whether the type and version of the current browser supports a particular version of JavaScript. Or, you can use the
HttpBrowserCapabilities object to determine whether the request originated from a mobile device.
The
HttpBrowserCapabilities object is driven by a set of browser definition files. These files contain information about the capabilities of particular browsers. In ASP.NET 4, these browser definition files have been updated to contain information about recently introduced browsers and devices such as Google Chrome, Research in Motion BlackBerry smartphones, and Apple iPhone.
Routing in ASP.NET 4
Asp.net add built in support for using routing in web farm.Routing is nothing it just configure URL does not map with physical URll, you can use routing for display URl in meaningful way. For Example you want to display article for cshap category
By routing you can configure Application can accept below URL to render same information above URL
Setting Client IDs
ASP.NET Chart Control
The ASP.NET Chart control expands the data-visualization offerings in the .NET Framework. Using the Chart control, you can create ASP.NET pages that have intuitive and visually compelling charts for complex statistical or financial analysis. The ASP.NET Chart control was introduced as an add-on to the .NET Framework version 3.5 SP1 release and is part of the .NET Framework 4 release.
The ability to persist selected rows in data controls
Gridview and listview control eable user to select row.In previous version of asp.net row selection is based on row index on page. For example if you select page1 item no 3 and move to page 2 then on page 2 item no 3 is selected, so it is not desirable.now in asp.net 4.0 support Persisted Selection, a new feature in asp.net 4.0 using PersistedSelection property of grideview or listview if property is true then if you go to page 2 then no item is selected if you go back to page 1 then item no 3 is selected.
<asp:GridView id="gdEmployee" runat="server" PersistedSelection="true">
</asp:GridView>
More control over rendered HTML in the FormView and ListView controls.
The
FormView control is enhanced to make it easier to style the content of the control with CSS. In previous versions of ASP.NET, the
FormView control rendered it contents using an item template. This made styling more difficult in the markup because unexpected table row and table cell tags were rendered by the control. Now in asp net 4.o have RenderTable property which can set true or false if we set false then control are not rendered as table and row html format so it is easier to apply css style on content of control.
<asp:FormView ID="FrvEmployee"
runat="server" RenderTable="false">
ListView
In ASP.NET 4, the ListView control does not require a layout template.
<asp:ListView ID="LvEmployee" runat="server">
<ItemTemplate>
<% Eval("LastName")%>
</ItemTemplate>
</asp:ListView>
CheckBoxList and RadioButtonList Control Enhancements
In ASP.NET 3.5, you can specify layout for the
CheckBoxList and
RadioButtonList using the following two settings:
- Flow. The control renders span elements to contain its content.
- Table. The control renders a table element to contain its content.
In ASP.NET 4, the
CheckBoxList and
RadioButtonList controls support the following new values for the
RepeatLayout property:
- OrderedList – The content is rendered as li elements within an ol element.
- UnorderedList – The content is rendered as li elements within a ul element.
Menu Control Improvements
Before ASP.NET 4, the
Menu control rendered a series of HTML tables. This made it more difficult to apply CSS styles outside of setting inline properties and was also not compliant with accessibility standards.
In ASP.NET 4, the control now renders HTML using semantic markup that consists of an unordered list and list elements. The following example shows markup in an ASP.NET page for the
Menu control.
<asp:Menu ID="MainMenu" runat="server">
<Items> <asp:MenuItem Text="Home" Value="Home" />
</Items>
</asp:Menu>
When the page renders, the control produces the following HTML (the onclick code has been omitted for clarity):
<div id="Menu1">
<ul>
<li><a href="#" onclick="...">Home</a></li>
</ul>
</div>
<script type="text/javascript">
new Sys.WebForms.Menu('Menu1');
</script>
Wizard and CreateUserWizard Controls
ASP.NET 4, you can create a LayoutTemplate template and insert PlaceHolder controls (using reserved names) to specify how you want the Wizard control to render. The following example shows this:
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" ActiveStepIndex="1">
<LayoutTemplate>
<asp:PlaceHolder ID="headerPlaceholder" runat="server" />
<asp:PlaceHolder ID="sideBarPlaceholder" runat="server" />
<asp:PlaceHolder id="wizardStepPlaceholder" runat="server" />
<asp:PlaceHolder id="navigationPlaceholder" runat="server" />
</LayoutTemplate>
<HeaderTemplate>
Header
</HeaderTemplate>
<WizardSteps>
<asp:CreateUserWizardStep runat="server">
<ContentTemplate>
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep runat="server">
<ContentTemplate>
</ContentTemplate>
</asp:CreateUserWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
Reference:
so guys we meet in few day with new topit
Thank you for Reading
Kirti M Darji