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")
)
)
Tuesday, January 1, 2013
How to add robots.txt into ASP.NET MVC site?
There are two ways to do so:
First one:
http://rayaspnet.blogspot.ca/2011/04/how-to-implment-dynamic-robotstxt-in.html
Second, the simpler one:
Add robots.txt into your website root, and Add one line into Global.asax file
First one:
http://rayaspnet.blogspot.ca/2011/04/how-to-implment-dynamic-robotstxt-in.html
Second, the simpler one:
Add robots.txt into your website root, and Add one line into Global.asax file
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("robots.txt");
}
Inside the ASP.NET Single Page Apps Template
http://www.johnpapa.net/inside-the-asp-net-single-page-apps-template/
Monday, December 31, 2012
How to ask user if want to leave current page in JavaScript?
Add function into onbeforeunload
var unsavedChanges = false;
window.onbeforeunload = function() {
if (unsavedChanges) return 'You have unsaved changes!';
}https://developer.mozilla.org/en-US/docs/DOM/window.onbeforeunload
Subscribe to:
Posts (Atom)