ASP.NET themes are great (in principle), and allow you to have lots of control on how your pages look with theme-specific skins, stylesheets, images etc. The only thing that’s a little bit annoying is that you can’t specify (without codebehind) what media the stylesheet should apply to.
If you add a new stylesheet to your theme folder called ‘printer.css’, ASP.NET will omit the ‘media’ attribute when it’s output to the <head> section, and it will then be subject to the normal order of precedence rules, affecting your screen output.
There may be other easy ways to do this, but W3C generally think of everything, and then the world catches up – so just use the @media rule to surround all your media-specific styles. The easiest way to organise this is obviously in different style sheets if you’ve got a complex layout. My simple ‘printer.css’ is below (along with the stylesheet link generated by ASP.NET).
This simply knocks out the left nav, right side bar and the footer (all divs of course), leaving a relatively clean page for printing.
<link href=”../App_Themes/corporate/printer.css” type=”text/css” rel=”stylesheet” />
Got sent this from a usability guy I sit next to. Looks very interesting and a lot rings true.
It’s on the internet so it must be right 😉
Does that mean I can go home now?
…but seriously, it does make you stop and think a little and get a bit of perspective
This is the sort of thing you shouldn’t need to know right..? ’cause you don’t use Oulook 2000 any more right..?
My new job still does and as I now can’t be bothered to write something (or buy something) to give me the outlook 2003-style ‘new message’ tray popup I found the following macro for other unfortunates in large companies (companies that take forever to upgrade software) who use this version. Application_NewMail is an event handler BTW…
Private Sub Application_NewMail()
Dim objNSMapi As NameSpace
Dim objMapiFold As MAPIFolder
Dim objNewMail As MailItem
Set objNSMapi = GetNamespace(“MAPI”)
Set objMapiFold = objNSMapi.GetDefaultFolder(olFolderInbox)
Set objNewMail = objMapiFold.Items.GetFirst
On Error GoTo CleanExit
If MsgBox(“You have new mail from ” & objNewMail.SenderName & ” [” & objNewMail.Subject & “]” & String(2, vbCrLf) & “Would you like to read it now”, vbQuestion + vbYesNo, “New Mail Notification”) = vbYes Then
Set objNSMapi = Nothing
Set objMapiFold = Nothing
Set objNewMail = Nothing
I hadn’t really used SiteMaps before, but it’s a useful feature of ASP.NET 2.0 (most people using them to drive BreadCrumb controls and site navigation).
After realising there was no support for design of the sitemap (apart from the default text editor) I found a simple (and functional) SiteMap editor here.
I then realised that I needed to add meta tags for each page in the site (NOTE: this is a simple ‘content’ site, so don’t come running to me if you have the need to generate specific tags based on what colour trousers the user is wearing!).
You can add new attributes very easily to the sitemap, and access them programmatically. The editor has a nice little grid to make this extra easy for you. In my example here we’ve added a ‘keywords’ attribute.
Assuming you’re using a treeview (or something similar) for navigation on your site and you’re binding to the SiteMap data source, then you’ll get the context of the current site map node in your page (or master page).
You can then use it to set your meta tags as follows:
You can also set Page.Title from currNode.Title etc.
This is actually quite a neat way to drive things like other standard properties of your master page – e.g. subheadings.
I’m currently without ReSharper (eek), so am trying to make the best of it. Looking around for VS 2005 addins (that I haven’t already got), I stumbled across a few resources….
Carl J has a list of Free Addins, and, wait – there’s another list…
Not forgetting Hanselman’s (old) list
I’m sure there’s more, but I don’t want to overcapitalise and slow my machine down more than Resharper did (maybe I should look at CodeRush?)