Posts

Showing posts from March, 2009

Eval: Sometimes I like spagheti code

I just discovered some interesting features of the construct <%# Eval() %> . Eval function uses reflection to evaluate a property of a bound object. I have two classes Product and Category and I want to display the available products in a page, by using a data bound control. public class Product { public int ID; public string Name; public int Stock; public DateTime Date; public Category Category; } public class Category { public string Name; public DateTime Date; } In a data template ( ItemTemplate for sample ) I can use the Eval function like: 1. very simple evaluation without using formats <%# Eval("Name") %> - will output the name <%# Eval("Stock") %> - will output the stock ( ..and so on ) 2. using a format <%# Eval("Date","{0:yyyy MMM dd}") %> - for sample: 2009 Apr 06 <%# Eval("Stock","{0} items") %> - will output "10 items" if the stock is 10 3. Co

Using UrlRewritingNet and Elmah together

  UrlRewritingNet is an Url rewriting tool for ASP .Net and Elmah is a module for logging unhandled errors.   UrlRewritingNet can set a default location for “directory” requests via defaultPage property in <urlrewritingnet> section. When a file without extension is requested the defaultPage value is appended to the original URL.    Elmah provides a handler for getting the errors summary, usually called elmah.axd. This handler also responds to the followings requests:    /elmah.axd/rss – RSS errors list feed  /elmah.axd/digestrss – RSS digest  /elmah.axd/download –  comma separated errors list /elmah.axd/about – about page  /elmah.axd/stylesheet – the stylesheet used /elmah.axd/detail?id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX – html single error summary  /elmah.axd/xml?id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX – xml single  error summary /elmah.axd/json?id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX – json single error summary    These requests are like a request for a file with