Archive

Archive for April, 2007

Points of Interest: ACM CareerNews: Tuesday, April 10, 2007

April 11th, 2007

“Keys to Retention” CIO.com, March 16

To increase employee retention, businesses should grant a higher degree of autonomy to their workers and provide them the tools to take on new challenges. … Other key factors include confidence in the leadership qualities of upper management, overall compensation levels and the degree of fit with the organizational culture. … The size of the organization also matters, with more employees showing a preference for smaller organizations where they are given more autonomy and more opportunities for career advancement.
http://www.cio.com/article/32557 

“Web Anonymity Can Sink Your Job Search” Computerworld, March 26

Having a presence on the Web is a critical factor in the job search, especially given the fact that a growing number of recruiters and hiring managers are using search engines when gathering data about potential employees. According to a 2006 survey, 77% of recruiters said they use search engines to check out job candidates. … In another survey … hiring managers said they use Internet search engines to research potential employees, … they also use social networking sites to screen candidates. All things being equal, most companies would rather hire a candidate who has demonstrated the ability to participate on the Web. Know where people look check what people will discover about you through popular search engines such as Google and Yahoo, … MSN Search or Ask.com … Review at least the first three to five pages of results. … use blog-searching tools such as Technorati, Daypop or Blogdigger … search specific sites, such as MySpace, YouTube or Flickr, … LibraryThing.comStart a blog Join the open-source code community. Build a Web page Create a Web profile Consider creating a Web profile on one of the many social and business networking sites … Naymz, Ziggs, FindMeOn.com and ClaimID.com
http://www.computerworld.com/action/article.do?command=viewArticleBasic&articleId=285324&source=NLT_CAR&nlid=5 

Original source: http://www.acm.org/careernews/issues/v3_i3.html

Author: Adam Kahtava Categories: Career News Tags:

Toronto Code Camp Was Great, My Highlights.

April 3rd, 2007

Windows Vista Programming with Kate Gregory – Kate briefly covered some of the exciting aspects of Vista Programming. Kate is an amazing speaker, and a true C++ guru, she may have sparked my C++ renaissance.

Barry Gervin’s impromptu session on Unit Testing and Visual Studio Team System (VSTS) – Barry gave an excellent presentation without a single power point, it was more of a question and answer period and Barry had the answers. Interesting topics included Test Driven Design (TDD) with VSTS, Team Foundation Server (TFS) Tips, and a brief overview the newest version of Visual Studio (Orcas) – which will have Unit Testing baked into the Professional / Developer version.

Chris Dufour’s great session on the Windows Communication Foundation (WCF), where the power of WCF and Service Oriented Architecture (SOA) were unlocked. Kudos to Chris he’s also the organizer of Toronto’s code camp.

It was a great event. I met a lot of great people with a common passion for development / programming. I’ll definitely be attending more, and I’m even toying with the idea organizing one here in Ottawa. :)

Author: Adam Kahtava Categories: Code Camp, Events Tags:

A Resolution to The Problems with Themes, Skins, and Cascading Style Sheets (CSS) – Putting the Cascades back into ASP.NET 2.0 Themes (taking control over CSS Cascades / Load Order, Media Types, and Overrides)

April 2nd, 2007

ASP.NET 2.0 Themes have a couple design flaws, all of which center around the way Themes reference Cascading Style Sheets (CSS). I’ve been posting Theme and CSS related issues and work arounds as I encountered them, and in one of my first posts I outlined the possibility of using a VirtualPathProvider to ignore the CSS files within a directory. In this post I share David Marzo’s implemented of this solution. This resolution resolves most of the issues surrounding Themes and CSS, and essentially puts the Cascades back into CSS.

The Problem / Question:
ASP.NET 2.0 Themes automatically includes all the Style Sheets (.css files) found in the active Theme (App_Theme) directory into the Head of the rendered document. This severely limits the robust CSS language, and works against the last decade of Cascading Style Sheet progress. For more specific details on the problems with ASP.NET 2.0 Themes start reading the articles found here.

A Solution / Work Around:
Add a custom VirtualPathProvider to ignore the Style Sheets (CSS files) found in the App_Theme directory. For more background on this solution see my article and David Ebbo’s article titled Overriding ASP.NET combine behavior using a VirtualPathProvider.

An example of the problem:

The directory structure:

Notice all the Style Sheets (.css files), there are more in the Adapters directory too.

Before including the CustomVirtualPathProvider (code provided below) into the project’s build – the XHTML rendered by Themes:

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head><title>The Problems With Themes and Skins in ASP.NET 2.0</title>
    <link href="App_Themes/Default/CSS/Adapters/ChangePassword.css" type="text/css" rel="stylesheet" /> 

    ... The other 17 externally linked Style Sheets go here, they were removed to improve readability ...

     <link href="App_Themes/Default/CSS/PrinterFriendly.css" type="text/css" rel="stylesheet" />
  </head>
<body>

The Style Sheets are automagically inserted into the Head tag from the active Theme directory. Keep in mind that Internet Explorer has a 30 Style Sheet limitation (see article Q262161).

After including the CustomVirtualPathProvider (code provided below) into the project’s build – the XHTML rendered by Themes:

<html xmlns="http://www.w3.org/1999/xhtml" > 
  <head><title>The Problems With Themes and Skins in ASP.NET 2.0</title>
  </head>
<body>

Notice the complete lack of Style Sheets – ahhh simplicity is bliss, the very foundations of CSS Zen Enlightenment… :) Now we can manually include our Style Sheets, use Conditional Comments, and so on.

The source code for the CustomVirtualPathProvider provided by David Marzo in C#:

namespace Arfila.Web.Logic {
 
 [AspNetHostingPermission(SecurityAction.Demand,
   Level = AspNetHostingPermissionLevel.Medium)]
 [AspNetHostingPermission(SecurityAction.InheritanceDemand,
   Level = AspNetHostingPermissionLevel.High)]
 public class CustomVirtualPathProvider : VirtualPathProvider {
 
   public static void AppInitialize() {
     HostingEnvironment.RegisterVirtualPathProvider(new CustomVirtualPathProvider());
   }
 
   public CustomVirtualPathProvider() : base() { }
 
   private bool IsThemeDirectory(string virtualPath) {
     String checkPath = VirtualPathUtility.ToAppRelative(virtualPath);
     return checkPath.StartsWith("~/App_Themes/", 
       StringComparison.InvariantCultureIgnoreCase);
   }
 
   public override VirtualDirectory GetDirectory(string virtualDir) {
     if (IsThemeDirectory(virtualDir)) {
       return new ThemeDirectory(Previous.GetDirectory(virtualDir));
     }
     else {
       return Previous.GetDirectory(virtualDir);
     }
   }
 }
 
 [AspNetHostingPermission(SecurityAction.Demand,
   Level = AspNetHostingPermissionLevel.Minimal)]
 [AspNetHostingPermission(SecurityAction.InheritanceDemand,
   Level = AspNetHostingPermissionLevel.Minimal)]
 public class ThemeDirectory : VirtualDirectory {
 
    VirtualDirectory _toFilter;
    private ArrayList _children = new ArrayList();
    private ArrayList _directories = new ArrayList();
    private ArrayList _files = new ArrayList();
 
    public override IEnumerable Children {
      get { return _children; }
    }
 
    public override IEnumerable Directories {
      get { return _directories; }
    }
 
    public override IEnumerable Files {
      get { return _files; }
    }
 
    public ThemeDirectory(VirtualDirectory toFilter) : base(toFilter.VirtualPath) {
      _toFilter = toFilter;
      BuildChild();
    }
 
    private void BuildChild() {
      foreach (VirtualDirectory dirToFilter in _toFilter.Directories) {
        ThemeDirectory themeDir = new ThemeDirectory(dirToFilter);
        _children.Add(themeDir);
        _directories.Add(themeDir);
      }
 
      foreach (VirtualFile fileToFilter in _toFilter.Files) {
        string fileExtension = VirtualPathUtility.GetExtension(fileToFilter.VirtualPath).TrimStart('.');
        if (string.Compare(fileExtension, "css", true) != 0) {
          _children.Add(fileToFilter);
          _files.Add(fileToFilter);
        }
        else {
          //archivo .css no incluir
        }
      }
    }
  }
}

Some of the code has been modified for readability, download the original source code here.

Note: In order to use this VPP you’ll have to copy the code above into a new class in your App_Code directory.

Caveat: If a Web site is precompiled for deployment, content provided by a VirtualPathProvider instance is not compiled, and no VirtualPathProvider instances are used by the precompiled site. – Taken from the article titled VirtualPathProvider Class on MSDN.


Conclusion:
This is one of the nicest work arounds or resolution to the issues surrounding ASP.NET 2.0 Themes. It allows us to leverage the power of ASP.NET 2.0 default Skins, allows us to logically group design related resources (Style Sheets, images, default Skins, videos, etc…) in the App_Theme directory, allows us to control the loading order (cascades) of style sheets, allows us to use Conditional Comments, to define Media Types, to override / inherit Styles, and to continue using CSS as it’s intended. In addition we can now easily integrate the ASP.NET 2.0 CSS Friendly Control Adapters into our web applications.

Author: Adam Kahtava Categories: .NET, ASP.NET, CSS, Themes and Skins Tags: