Friday, January 4, 2013

How to know if .Net Framework 4.5 installed?

.NET 4.5 is not running side by side with .Net 4.0. It is a upgrade.
.NET 4.5 overwrites .NET 4. So all of files are in the same folder.

Following are the different version for .Net 4.0
4.0.30319.1 = .NET 4.0 RTM
4.0.30319.269 = most common .NET 4.0 version we're seeing in the data collected from our users
4.0.30319.544 = another .NET 4.0 version that a small portion of our users have installed
4.0.30319.17626 = .NET 4.5 RC
4.0.30319.17929 = .NET 4.5 RTM
4.0.30319.18010 = current version on my Windows 8 machine

So there are many ways to know if .Net 4.5 installed
1. By System.dll version number: 4.0.30319.17626 or greater
2. By Registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client
3. By code
  public static bool IsNet45OrNewer()
  {
      // Class "ReflectionContext" exists from .NET 4.5 onwards.
      return Type.GetType("System.Reflection.ReflectionContext", false) != null;
  }

SignalR: Building real time web applications

http://blogs.msdn.com/b/webdev/archive/2012/12/17/signalr-building-real-time-web-applications.aspx

Thursday, January 3, 2013

How to disable double click event by jQuery?

$("*").dblclick(function(event){
event.preventDefault();
});

Wednesday, January 2, 2013

How to map part of table (only for specific columns) in Entity Framework?


No, you can’t.
The workaround is to create store procedure or view, the map from there

Exporting The Razor WebGrid To Excel

http://www.mikesdotnetting.com/Article/204/Exporting-The-Razor-WebGrid-To-Excel

@{
    Layout = null;
    var db = Database.Open("Northwind");
    var sql = "SELECT CustomerID, CompanyName, ContactName, Address, City, Country, Phone FROM Customers";
    var data = db.Query(sql);
    var grid = new WebGrid(data, canPage: false, canSort: false);
    Response.AddHeader("Content-disposition", "attachment; filename=report.xls");
    Response.ContentType = "application/octet-stream";
}
@grid.GetHtml(
    columns: grid.Columns(
        grid.Column("CustomerID", "ID"),
        grid.Column("CompanyName", "Company Name"),
        grid.Column("ContactName", "Contact Name"),
        grid.Column("Address"),
        grid.Column("City"),
        grid.Column("Country"),
        grid.Column("Phone")
    )
)