Andornot Consulting Inc.
Home Page
Home Page
 |  | 

Thursday, May 01, 2008

Keyboard shortcut goodness: instantly size all columns in Windows Explorer!

Is just one shortcut worth a whole blog post? Yes.

I love keyboard shortcuts. I especially love it when I come across one that removes regular angst-causing silly stuff. One great silly-stuff-zapper shortcut is described in a post I just stumbled upon by James Blackwell.

A horrible thing about Vista: goofy things that happen in Windows Explorer. One of these Windows Explorer things in all versions of Windows, including Vista, is the way the views never show properly. in Vista, if you're lucky enough to have your Explorer window actually list files without thinking you're always in media mode (if you use Vista Ultimate or Vista Premium, you'll know exactly what I'm talking about), you're still never really fortunate enough to immediately see entire file names etc. as shown here: 

image

Press  Ctrl-+ (that's the Ctrl key along with the "+" key on the number pad) and voila:

image

All column names are sized as applicable in one fell swoop! Amazing! No more fumble-finger double-clicking on each column, which in Vista is even more fumblefingery than before.

Thank you Mr. James Blackwell. I don't know you, but you're a fine fellow (and yes, it was nice to first see "What Application Pool does this W3WP.EXE belong to").

UPDATE: As per one of the comments, yes this is still possible for a laptop. You just need to switch into numpad mode by holding down one more key usually called "Fn". And it's usually blue. Unless it's Denise's new laptop in which case it's probably red...because she likes it that way. So Ctrl-Fn-Shift-= makes it work on a laptop.

Labels: ,

Friday, February 01, 2008

Visual Studio and the non-sensical "Apply Cut Copy commands to blank lines where there is no selection" option.

Quoting some comments in Jeff Atwood's "Revinventing the Clipboard" blog post:

What I dislike the most, about the clipboard, is the really bad behaviour in VS. Say you cut something, then you try to past it elsewhere but you hit the C instead of the V (without any text selected) and bravo, you've lost your clipboard content! You now have to undo 3 or 4 times to re-start the manipulation. This is anti-productive at the most.

Fabian on January 22, 2008 03:01 AM

Fabian: That one gets me too, but the good news is that you can turn off that behaviour in Visual Studio.

Go to Tools->Options...->Text Editor->All Languages->General and untick "Apply Cut Copy commands to blank lines when there is no selection"

(I guess this goes towards what Jeff was saying about software having reasonable defaults).

GrahamStw on January 22, 2008 03:10 AM

It's one of those things that I never remember how to reset so here it is. Glory Hallelujah.

And btw, using ClipX and loving it (and yes, the beta seems to work fine in Vista).

Labels: , , , ,

Monday, October 15, 2007

Helpful Visual Studio tip: automatically insert attribute values when typing

In Visual Studio 2005, the default is to not automatically insert attribute value quotes when typing in the HTML editor. I don't like that. If you're like me, change this default behaviour by going to Tools -> Options -> Text Editor -> HTML -> Format. Then check off "Insert attribute value quotes when typing."

Insert attribute value quotes when typing. 

On another note, you'll notice the "Insert attribute value quotes when formatting" checkbox right below. This is on by default; I find it very useful in that one of my favourite shortcut key chords (ctrl-K, ctrl-F) not only formats the selected text, but also then automatically enters any missing attribute value quotes.

Labels: ,

Thursday, June 28, 2007

ResolveUrl vs. ResolveClientUrl

The .NET Control class methods ResolveUrl and ResolveClientUrl both take a relative URL as a parameter and return relative URLs for client browser use. So what's the difference between them?

In simple terms, ResolveClientUrl returns a path relative to the current page, and ResolveUrl returns a path relative to the site root. Both methods are particularly useful when passing in a relative URL prefaced with the tilde (~) to indicate the application root.

Let's say we have an image in a layout directory, and a page which needs to pass a usable relative URL for the image to the client browser.

image http://www.andornot.com/layout/images/andornotLogo.gif

page http://www.andornot.com/Products/Default.aspx.

Here is what we would get if we called the two methods from our Default.aspx page.

Page.ResolveUrl("~/layout/images/andornotLogo.gif")
"/layout/images/andornotLogo.gif"
Page.ResolveClientUrl("~/layout/images/andornotLogo.gif")
"../layout/images/andornotLogo.gif"
There is more to it, of course, particularly since these are Control methods, not exclusively Page methods. It's pretty straightforward to see how paths relative to a page resolve, but not necessarily so obvious when the control is being instantiated in a UserControl or MasterPage.

ResolveUrl uses the Control.TemplateSourceDirectory property to do its job, and that property value is the virtual directory of the Page or UserControl that contains the current server control.

ResolveClientUrl returns a URL relative to the folder containing the source file in which the control is instantiated.

Labels: ,

Wednesday, June 27, 2007

Type-safe access to the current page's URL

Virtually every web project you work on requires that you get the current page's complete URL. Years ago, I got tired of using non-type-safe ways of munging together various Request.ServerVariables to get it (anyone remember stuff like "If Request.ServerVariables("HTTPS") = "on" Then..."?) and with .NET there had to be a better way. Due to a dearth of non-Request.ServerVariables examples out there back then, it took trusty trial and error Response.Write tests and the MSDN help to settle on the following:

Request.Url.Scheme + Request.Url.SchemeDelimiter + Request.Url.Authority + Request.Url.PathAndQuery

While I never understood why I still had to parse these together (and I sporadically investigated alternatives), it nevertheless felt so much better than parsing together strings like "://" with icky stuff like Request.ServerVariables("SERVER_NAME").

But yes, there had to be an even better way: a way that resisted forgetfulness and the ensuing battle with more than vague intellisense descriptions. Since I'm slow, it was only today that I found it. My my, sometimes I do miss the obvious:

Request.Url.ToString()
returns the canonically unescaped form of the URI (i.e. "http://www.example.com:80//thick and thin.htm")

and/or

Request.Url.AbsoluteUri
Returns the canonically escaped form of the URI (i.e. http://www.example.com:80//thick%20and%20thin.htm)

And yes, I had tried out AbsoluteUri before (I must have, right?), but for some reason, I still missed it.

Labels: ,