August 2010 Entries

Setting a Master Page Dynamically

To set an ASPNET master page dynamically, use the Page_PreInit function and set the Page.MasterPageFile property. For example: protected void Page_PreInit(object sender, EventArgs e) { this.Page.MasterPageFile = "~/MasterPages/" + mymaster + ".Master"; } In the above example, mymaster should be set by whatever your requirements dictate – read from DB/CMS/whatever. The page (aspx) itself shouldn’t have any other reference to the master page (ie, no “MasterPageFile attribute in the page directive), ......

Posted On Tuesday, August 17, 2010 3:04 PM | Comments (2)

PowerShell TruncateAtWhitespace Function

Here’s a TruncateAtWhitespace function that takes an incoming parameter value and an incoming max length, and returns a substring broken at a whitespace position. This way if you have “Lance has a blog” and you need to truncate it to 8 characters or less, you get “Lance” instead of “Lance ha”. function TruncateAtWhitespace{ param( [string]$value, [int]$maxlength=200 ) $maxlength-=3; #allow for "..." suffix if ($value.Length -le $maxlength) { return ($value + "..."); } $closestwhitespaceindex = [int]$value.Substring(0, ......

Posted On Monday, August 16, 2010 3:30 PM | Comments (0)

CSharp TruncateAtWhitespace Function

Here’s a TruncateAtWhitespace function that takes an incoming parameter value and an incoming max length, and returns a substring broken at a whitespace position. This way if you have “Lance has a blog” and you need to truncate it to 8 characters or less, you get “Lance” instead of “Lance ha”. /// <summary> /// Truncate at the end of a word /// </summary> /// <param name="value">The original string</param> /// <param name="maxlength">The maximum length of string to return</param> ......

Posted On Monday, August 16, 2010 3:28 PM | Comments (0)

Remote Desktop Copy and Paste Clipboard Stopped Working

Seemingly out of the blue, copy and paste from my local desktop to Remote Desktop stopped working.  I had to resort to *gasp* FTP (ok, so it wasn’t that big a deal but it was still annoying to me).  Anyway, the solution turned out to be very simple:  On the remote machine, just bring up the task manager and kill and restart rdpclip.exe.  Voila, problem solved.

Posted On Monday, August 16, 2010 2:41 PM | Comments (1)

Dynamic Configuration of Log4Net

I needed to dynamically configure log4net – outside of the web.config file. Here is my solution: 1. All that configuration of log4net in web.config? Forget it. 2. Create a separate log4net.config file (name it whatever you want), with the usual configuration content in it defining whatever appenders you want. For example if you want a rolling file log: <log4net> <appender name="RollingLogFileAppender" type="log4net.Appender.Roll... <param name="File" value="C:\\Temp\\mylog.txt" ......

Posted On Friday, August 13, 2010 7:18 PM | Comments (0)

Gettin’ Hitched

What’s new with you? So yeah, I have been quiet lately. As you may remember, I left /n software in March and joined a new startup company in Chapel Hill called 3Birds Marketing. What have I been doing since? Lots! First and foremost, I got engaged to the wonderful and beautiful Lauren Briggs. Yep, I’m gettin’ hitched. I’m a lucky man because #1 she’s awesome, #2 she’s smart as hell, #3 she’s hot, #4 she’s fun, and #5 she kicks ass. Seriously. Don’t mess with her or she will beat you up. Life at 3Birds ......

Posted On Friday, August 13, 2010 6:44 PM | Comments (3)

Copyright © Lance Robinson

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski