# Thursday, February 21, 2008

Using print stylesheets with ASP.NET Themes

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" />

 

posted on Thursday, February 21, 2008 8:32:01 AM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]
# Wednesday, February 20, 2008

Top 10 Application Design Mistakes

Got sent this from a usability guy I sit next to.  Looks very interesting and a lot rings true.

 

posted on Wednesday, February 20, 2008 9:36:54 AM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]

Do Web Sites need to look exactly the same in every browser?

It's on the internet so it must be right ;-)

http://dowebsitesneedtolookexactlythesameineverybrowser.com/

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

posted on Wednesday, February 20, 2008 7:52:20 AM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]
# Monday, February 11, 2008

Retro : Show popup for new mail in Outlook 2000

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

ShowMessage:

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
    objNewMail.Display
Else
    objNewMail.Close olDiscard
End If

CleanExit:

MsgBox Err.Description

Set objNSMapi = Nothing
Set objMapiFold = Nothing
Set objNewMail = Nothing

End Sub

posted on Monday, February 11, 2008 7:54:14 AM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]
# Wednesday, February 06, 2008

Programmatically add Meta Tags to ASP.NET Master Pages using a SiteMap

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. 

posted on Wednesday, February 06, 2008 4:46:54 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]
# Tuesday, February 05, 2008

Free Visual Studio 2005 Addins

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?)

posted on Tuesday, February 05, 2008 8:26:32 AM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]
# Friday, February 01, 2008

Microsoft Boy at School

posted on Friday, February 01, 2008 1:53:26 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]
# Thursday, January 31, 2008

Programmers Fonts

I'd only really tried Monaco (still the favourite) in Visual Studio, but found a good collection of programmer's fonts here.

posted on Thursday, January 31, 2008 12:27:41 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]
# Tuesday, January 29, 2008

Passage - A game to ponder

Just found this game.  (explained fully on the Wall Street journal site).  As a male it's worth looking at to experience a rather insightful look into the effects of choices we make in our lives (only takes 5 minutes).  I'm rather glad I'm married...

posted on Tuesday, January 29, 2008 8:05:40 AM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0]