code Articles

Highlighting the CurrentNode in a ASP.Net UL menu

February 18 2009

Another quick snippet again folks. This time I’m using an ASP.NET sitemap provider to populate a repeater that generates an unordered list. The end user wants the current page to be highlighted in the menu, so I’ve set up a class called current-page in the stylesheet which will make this text bold.

Then I add the following to the reapeater item template code.

<li <%# currentPage(Eval("Url"))%>>

After doing that, the final stage is to add the following to the .cs file of the menu user control. This code compares the url output by the SiteMapProvider with the CurrentNode url of the page. If it finds a match, it adds the class to the list item.

protected string currentPage(object tURL)
{
 string cnURL = SiteMapProvider1.Provider.CurrentNode.Url.ToString();
 string cp;
 if (cnURL == tURL.ToString())
 {
   cp = "class=\"current-page\"";
 }
 else
 {
 cp = "";
 }
 return cp;
}

That’s pretty much it! If anyone has a more efficient way of doing this, drop me a line or comment.

Rails issue solved

February 10 2007

Wee post to express my thanks to Jonathan Linowes of Vaporbase for the advice on the issues I had with Ruby on Rails.
After reading the first page of his RoR setup, I went through the hidden files on my user directory. Noticing how similar the conent of .bash_login (amended for ruby) and .bash_profile (generated by MacPython) I ameded the latter to include the statements of the former and I now have both a working version of Ruby on Rails and Django. Love it when a plan comes together.

Now to test my true nerd power as I simultaneously develop a site in both Django and Ruby on Rails and let the client choose…..

Jimbo’s got a brand new bag

February 8 2007

My lovely new vaude bag arrived in the mail today, nice and roomy, with a removable laptop shell, perfect for taking a macbook and my d50 to various conferences and generally out and about.

Working on an asp.net microformats implementation that I reckon might be useful at work, if not I may just release the code here for folks to tinker with.

Now back to 24 season 5…..

Full Size Windows Bookmarklet

August 14 2006

So I know it’s a silly thing, but something that’s always bugged me with Apple browsers is that the maximise button on the left hand side only expands to the width needed for the currently loaded page. Now the thing is, the internet is full of diversely dimensioned pages and I like most people hate horizontal scrolling, so to speed things up I put this bookmarklet together:

fullscreen
(drag and drop onto links bar)

It’s basically Zeldman’s bookmarklet for browser resizing, only with my screen size (the 1440 bit) in there.
So I figure if there’s any mac users out there who wanna browse at full screen and can’t be bothered dragging the corner of the window, this may come in handy.