This is a quick tip about how to reach the Navigation Bar via the keyboard (in Visual Studio) and it’s shamelessly reproducing that post by Scott Cate, not because I think I’m adding anything new but because I wanted to be able to find it again easily.

Navigation-BarThe Navigation Bar is just below the tabs in Visual Studio and has 2 drop downs; the first lists objects in the current file and the second lists the members of the selected object. This can be a very quick way to navigate around your class file, though the CodeRush Quick Navigation is more powerful IMO.

So to jump up to the Navigation Bar press Ctrl+F2, then you can tab between the left and right drop downs. When you’ve selected the member you want to move to press enter to have the cursor and focus move to that selection.

Incidentally I thoroughly recommend Scotts’ VSTricks category, which is in turn replaying Sara Ford’s Tip of the Day posts in video format.

Tags: , | Categories: Tips&Tricks | Visual Studio

I am setting up my new work PC at the moment and Visual Studio kept telling me there were updates for NuGet. Dutifully I tried to run the update but it kept failing, I tried to run VS as an admin but due to the way it is installed on the network that wasn't possible. Uninstalling NuGet from the Uninstall Program option in Control Panel removed it from the list of installed programs, but not from Visual Studio, so then I thought I'd try some brute force and just remove the whole folder to see if that helped. 

That got me somewhere, now Visual Studio didn't think NuGet was installed, but I couldn't install it either... Well if there's a brute force way to remove the extension then there's a brute force way to install the extension and that's simply to download the NuGet.Tools.visx then extract it to C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\NuGet (this folder may not exist, or you might have previously removed it with the brute force approach). After extracting the contents of the visx I relaunched Visual Studio and now have NuGet Version: 2.1.31002.9028, though the Disable and Uninstall buttons are greyed out (lack of admin rights I guess), so next time I need to update it looks like I'll need to repeat my "Uninstall" process, which is why I wrote this post... to remind me Wink

Tags: | Categories: Development | Tips&Tricks

This is a quick tip for sorting emails in Outlook. It took me ages to figure out how to sort by folder and then by received in ascending order.

When I say it took me ages I posted this as a question on superuser.com on 5th May 2010 and have yet to receive any answers! However I have a solution and I’m quite pleased about it, so I’m sharing it with you.

The problem I wanted to solve was that of sorting my emails in Outlook; I want my emails / rss presented to me in folders (which Outlook does by default) but I wanted to see them in the order in which they were sent and Outlook always wanted to show me the most recent first. Well that’s no good, cause sometimes those emails refer to something that’s been said before and I like to process my emails top to bottom. I’m quite quick at this processing; using the arrow keys I’ll move down the list deleting anything that looks dull or too long (or skipping past it for later reading), but when the emails are out of order that’s a mental obstacle and it annoys me.

My first attempt to solve this, as I said in the superuser post was to click to sort by the “In Folder” header then hold down the shift key and clicking Received twice. However this is not persisted at all, even just checking the calendar causes the settings to be lost.

The solution is to set the Sort order to In Folder (ascending), Received (ascending) and Group By to In Folder (ascending). The easiest way for me to describe how to get to the Advanced View Settings screen is to select the View menu, then View Settings option. In “Sort…” set the Sort items by “In Folder” (ascending), Then by to “Received” (ascending) and OK.

Next in the “Group By…”

  1. Uncheck the top box “Automatically group according to arrangement”
  2. In “Select available fields from:” choose “Frequently-used fields”
  3. Then Group items by “In Folder” (ascending) and make sure “Show field in view” is checked

Ok that, your emails will now be presented to you in the order they were sent and grouped by the folder they’re delivered into.

GroupBySettings

Tags: | Categories: Tips&Tricks

In my quest to truly master the keyboard I have now added a new shortcut to my skills, how to close the current tab in Visual Studio 2010.

Ok I realise this might not be news to many, but I only just found out today how to do it so I’m quite pleased. Ctrl+F4 is your friend. I’ve become quite good at navigating around a project using just the keyboard, either with F12 or Ctrl+Alt+N (CodeRush keystroke), getting back through that is easy, I just press Esc and CodeRush takes me back to each previous place in my code. What I don’t like is that I often end up with loads of open tabs and I don’t like that kind of clutter – it’s hard to find the bits I actually want. So now I just need Ctrl+F4 and the tabs will close one after the other.

The only problem I have with this is that I got confused between Ctrl+F4 and Alt+F4 (which just closed Visual Studio entirely – not what I was after!)

Tags: | Categories: Tips&Tricks

This is a really simple but very useful productivity tip for Outlook.

I like to use my email list in Outlook as a to-do list of sorts; emails come in all the time and once or twice a day I’ll look through them. I used to be ‘addicted’ to email, I’d have Outlook open all the time on 1 screen or I’d have the system tray icon pop up when new mail arrived, then I’d stop what I was doing to read the email. At work we get quite a lot of emails, meeting requests and background noise so this was very quickly becoming quite a time sink for me.

Now, as I said, I’ll check through a couple of times a day (usually when I’ve finished coding something and just want a quick break), my goal is to keep my inbox (and other folders) empty so if I like to scan down my emails and delete / archive as many as I can. My preferred ‘view’ is Unread Mail and I have that sorted by folder, so all emails from a given sender are grouped together. The problem I have been having with that is the emails are then sorted with the newest at the top of the group. It is really handy seeing all my emails and rss grouped together but the newest on top is the wrong way round for me. Unfortunately when I’ve tried to change the sort order and say:
Sort by – Folder, then by Received Outlook does a double sort and my emails are jumbled together.

My tip is to hold down the Shift button when clicking the header. So for me to get my emails sorted by Folder and then within the folder to have the oldest emails at the top (so I can process them in order) I click on the Folder header, hold down the Shift key and then click the Received header two times, the first activates that column (but with the wrong sort order), clicking it again sorts it ascending order. I’m now a happy (and marginally more efficient) developer!

Update 05/05/10

Ok, seems that my tip has a flaw. The sort works a treat but if you change your view in Outlook to another folder and then return expecting the custom sort to still be there… you’ll be disappointed. I’m not sure why but Outlook doesn’t seem to remember the sort properly, it ends up jumbling up the sort. I’m not sure if this is just an Office 2010 (beta) issue or more widespread at the moment.

Tags: | Categories: Tips&Tricks

The premise for this is quite straightforward, I’m using an ASP.NET Repeater control to display the results of a query – one row per item. As an example I’m going to display a list of students and a Checkbox IFF the data allows. To do that I need to create a function in the code behind and then pass my arguments to it from within my repeater.

Unfortunately Repeater controls do not allow you to embed <% if … %> statements, otherwise I could do something like this:

<ItemTemplate>
    <tr>
        <td class="contactNoCol"><%#Eval("ContactNo")%></td>
        <td><%#Eval("FullName")%></td>
        <% If String.IsNullOrEmpty(Eval("SelectText")) Then%>
        <td class="chkColumn"><%#Eval("SelectText")%></td>
        <% Else%>
        <td class="chkColumn"><asp:CheckBox ID="chk" runat="server" /></td>
        <% End If %>
    </tr>
</ItemTemplate>

Using this approach will result in an error: “Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.” Annoyingly it isn’t valid to use this kind of logic in the repeater, despite the fact that Visual Studio helped me write it by providing me with intellisense.

To get around that I moved the logic to a function in the code behind. This has a few advantages, the logic can be a lot more complicated and it keeps the aspx file a bit cleaner / free from the logic. This is how I’m doing it now:

<ItemTemplate>                    
    <tr>
        <td class="contactNoCol"><%#Eval("ContactNo")%></td>
        <td><%#Eval("FullName")%></td>
        <td class="chkColumn">
            <asp:CheckBox ID="chk" runat="server" Visible='<%# ShouldShowIf(False, Eval("SelectText")) %>' />
            <asp:Literal ID="ltSelectText" runat="server" Text='<%#Eval("SelectText")%>' 
                Visible='<%# ShouldShowIf(True, Eval("SelectText")) %>' /></td>
    </tr>
</ItemTemplate>

The function ShouldShowIf is declared in the code behind for this page:

Public Shared Function ShouldShowIf(ByVal returnBool As Boolean, ByVal value As String) As String
    Return If(value.Length > 0, returnBool, Not returnBool)
End Function

ShouldShowIf takes 2 arguments, the value to evaluate and the flavour of the Boolean to return. I needed to allow the calling code to determine whether it should return True or False because the checkbox should be shown if the SelectText is empty otherwise it should display the SelectText value.

I’ve used this approach before, but forgot about it – so I’m posting it up in the hopes that it helps someone else, if nothing else it will serve to remind me how to do this in future.

Tags: , | Categories: ASP.NET | Development | Tips&Tricks

We have just got a new (virtual) server at work to use as a continuous integration server which I plan to also use as a source control / subversion server. This means I need to move all existing repositories from their current server to the new one. What I didn’t want to happen was to need to delete and recreate all working copies in order to use the new repositories.

All my searching seemed to point to a command line approach; creating a dump of the repository on the old server, loading that dump on the new server and then using svn switch –relocate oldurl newurl (or the switch command from TortoiseSVN)- I tried this but kept getting an error saying:

https://oldserver:8443/svn/MyRepository
is not the same as
https://newserver:8443/svn/MyRepository

So I did a bit more googling around the ‘is not the same repository’ error, checked to make sure that the new repository was using the same uuid as the old one, which it was (use svnlook uuid path/to/repository). Then, just as I was about to give up for the night and go home I found the answer and it was much easier than anything I’d tried before.

Moving repositories between servers

First you need to move the repository to the new server. I am using VisualSVN Server which makes this very easy; right click on the Repositories root node then go to All Tasks then Import Existing Repositoryimport

This brings up a dialogue for you to browse to the original repository. browse-for-svn

When you do this it copies the entire repository over (complete with its uuid) and includes all history, every commit and the ability to roll back to any previous version!

Update clients and working copies

Next you need to update your working copies; right click on the WC, go to TortoiseSVN menu select Relocate and simply enter your new repository address.
relocate

This updates all references in your WC to the new repository and from that point on you will be updating from and committing to the new repository.

Easy eh! Now I’ve just got to move another 30 or so repositories and I can turn off the old repository server.

Tags: , , | Categories: Development | Tips&Tricks

I just found out about a (greatly under publicised) tool that shipped with Vista SP2, looking around it seems there was also something similar for SP1 called the Vista SP1 File Removal Tool.

Anyways the tool is called compcln.exe and running it from a command prompt recovers your free disk space by removing SP1 backup files that were not removed by the SP2 setup. The price you pay is not being able to remove the Service Pack.

I was able to recover almost 1GB of free disk space after doing this.

Tags: , | Categories: Tips&Tricks

Ok I don’t often have to deal with ColdFusion, but at work there are still a few legacy websites using it and every so often I have to make some updates / changes (at least until we’ve finished migrating things over to .Net, and Sitefinity). However this morning I needed to make a change one of the forms so as well as saving details to the database, it also emails the results to someone.

One of the nice things about Coldfusion is that it is pretty easy to use, there are quite a few handy tags to use and cfmail is one of those, set a few properties on the attributes (such as who the mail is from, who its going to and the subject) the content for the mail message is simply everything between the start and close tags. To put text on the next line you simply add a line break (not \n or <br /> or VbCrlf), so it’s treated a bit like a <pre> tag, but it seems that only works IFF the end of the line is not an output (wrapped in # markers). When the last thing on the end of the line is wrapped in output markers cfmail ignores the fact that you’ve added a line break, you can add another line break but then cfmail adds both line breaks. You could make the whole email an html mail, but then you’d have to control all line breaks with a <br /> tag and that’s more hassle than its worth (for a simple email anyway).

The solution I landed on was simply to add a character to the end of the line, in my case a full stop (period) ‘.’ character was a good candidate. Somewhat obscure, though I can understand why it behaves like that, a bit like C# something has to indicate that the code block is over and ‘normal’ html should resume.

Tags: | Categories: Development | Tips&Tricks

I just upgraded my pc at work from XP to Windows Vista Business, yes I actually mean upgraded rather than a clean install. Ordinarily I wouldn’t have gone down the upgrade route but for various reasons I couldn’t afford to wipe my pc and start again at the moment.

Everything seemed ok, the upgrade process, though a little slow, completed alright. However none of my websites that were running in IIS were now running; I was getting HTTP Error 500.19 – Internal Server Error in IIS 7.0, not good. I checked permissions on applicationHost.config and couldn’t see anything wrong, then, after figuring out how to enable Request Tracing request-tracingand realising there was nothing in the folder, so nothing wrong. Next I had a look at my web.config file, though I didn’t really expect there to be anything wrong with the config as I had been using this site before upgrading to Vista.  Nothing out of the ordinary there.

Finally I decided to reinstall the .Net feature of IIS 7.0, to do this go to:
Control Panel > Programs and Features, then from the Tasks bar on the left side select Turn Windows features on or off, expand Internet Information Services, then World Wide Web Services, Application Development Features then uncheck ASP.NET click OK and then come back and check the boxwindows-featuresHope this helps

Tags: , , | Categories: ASP.NET | Development | Tips&Tricks