Showing posts with label web browser. Show all posts
Showing posts with label web browser. Show all posts

Friday, August 5, 2011

Avoid DataBinder.Eval in ASP.NET and improve Performance


I see a lot of developers using DataBinder.Eval, which evaluates data-binding expressions at run time. Although the DataBinder.Eval is quite frequently used in web controls like the GridView, Repeater etc, use it with caution. Here’s what the documentation says

Because this method performs late-bound evaluation, using reflection at run time, it can cause performance to noticeably slow compared to standard ASP.NET data-binding syntax.
Let’s take an example to see how to avoid using DataBinder.Eval. Here’s some code that uses DataBinder.Eval() to display Person details







Although the markup looks tidy, for a large number of rows and columns, you are executing Eval() that many times, which will reduce performance since DataBinder.Eval() uses reflection to evaluate the data-binding expressions.
To avoid using DataBinder.Eval you can use the following alternatives:
For ObjectDataSource
If you are using an ObjectDataSource, refer directly to the Person class as shown below:
<asp:Repeater ID="rptPerson" runat="server">
    <ItemTemplate>
 <%# ((Person)Container.DataItem).FirstName %> 
<%# ((Person)Container.DataItem).LastName  %> 
<%# ((Person)Container.DataItem).Age  %>     
    </ItemTemplate>
</asp:Repeater>
For SqlDataSource
If you are using a SQLDataSource with a DataTable, use the following markup to cast the Container.DataItem as a DataRowView
<asp:Repeater ID="rptPerson" runat="server">
    <ItemTemplate>
        <%# ((DataRowView)Container.DataItem)["FirstName"] %> 
<%# ((DataRowView)Container.DataItem)["LastName"]%> 
<%# ((DataRowView)Container.DataItem)["Age"]%> 
</ItemTemplate>
</asp:Repeater>
Note: If you are using SqlDataSource with the DataReader mode, use DbDataRecord.

Saturday, June 18, 2011

Microsoft Launches IE9 Mobile Test Drive Site

Web developers who want see how their sites will look on the new version of IE 9 Mobile, which will soon ship along with Windows Phone 'Mango,' the next-generation update to the Windows Phone mobile OS, now have a new tool to do so. Today, Microsoft has launched Mobile Test Drive, a companion to the Internet Explorer Test Drive site for the desktop. The new site features a number of HTML5 and performance demos highlighting IE 9 Mobile's capabilities.

Ie9 mobile test site
The mobile site is organized much like its desktop counterpart and includes may of the same samples in addition to several mobile-specific ones.
Over the next few months, even more samples will be added as we get closer to Mango's commercial release, says Microsoft. Mango is expected later this fall.
Currently, the first 15 samples on the new site include the following:

  • Audio Player (from MIX11)
  • Geolocation
  • Border Radius
  • DOM Local Storage
  • Scalable Vector Graphics
  • CSS3 Media Queries
  • DOMContentLoaded
  • FishIE Tank
  • Speed Reading (from MIX11)
  • Animated Text
  • HamsterDance Revolution
  • Business Charts
  • IE Logo
  • Video Panorama
  • Browser Control Theming