ASP.NET Server Tags

There are a number of different server tags (<%, <%#, <%$, <%@, <%=) which each mean different things.

This article goes into a little depth talking about each of these tags.

The one I never use, is <%$, which I learned is for displaying expressions, but you can also easily write your own expression provider by extending the expressionbuilder class.  An example of doing so can be found here.

Pretty cool.

VS.Net Go To Implementation

Visual Studio has a nice “Go to definition” shortcut, but with our MVP pattern we are doing a lot of work against interfaces, which means that quite often going to definition actually takes us to a method in an interface.  For example:

Dim e As IEmployee = New Employee(1234)
Call e.GiveRaise(1.05)

If you did “Go to Definition” on “GiveRaise” you would not end up in the Employee class, but rather than IEmployee interface.

This plugin helps fix that problem.

I ended up skipping that part where he sets up the keyboard shortcut in favor of just using right click, but if you want to set that up you might find that the menu item he talks about is missing.  To get that dialog to show up use the keyboard shortcut CTRL+ALT+SHIFT+O.

 

OpenOfficespace.com

Companies that have unused office space can sublet it to individuals or other small group swho need an office but can’t afford the full deal.

It’s great for independent contractors who want to have an office outside of their house.

http://openofficespace.com attempts to make these arrangements (and other more standard office space) easy to list/find.  While it “kinda” worked for me, the implementation is really lacking.  Lots of the results that came back were not in the specified area radius and some that WERE were not shown until I modified my location.

People listing $0/month is also quite useless for people who don’t want to have to call the agent to find out that actual asking price.

But still, probably a useful resource.

Threaded Comments Database Schema

Interesting post on how to use a different schema strategy for nested comments that doesn’t involve a recursive hierarchy:

http://stackoverflow.com/questions/3763273/asp-net-threaded-comments

———————–

One approach I remember seeing somewhere was rather than using a Comment ID and a Parent ID , comments had a Comment ID and a “sort key” which was a concatenation of all the Comment IDs of their ancestors.

E.g. If comment 1 had two replies, comments 2 and 3, the sort keys would be:

1 : 0001
2 : 0001.0002
3 : 0001.0003

Then if someone replied to comment 2, it would be..

4 : 0001.0002.0004

So if you select all comments and sort by this sort key, they’ll fall out in the right order.

Then, to do the indenting, you simply look at the length of the sort key to see how many levels deep the comment is, and indent an appropriate amount.

Adding comments is easy: the sort key of the new comment is simply it’s parent’s sort key, with its own ID added on to the end.

———————–

Obviously you’d have to pad the ID values sufficiently.  In addition, if you wanted to just show comment 12345 and all children, you could just display the thread where code like ‘%00012345%’.

Aligning TABLE inside TDs

I inherited a web app that has a structure like this:
table
  tr
     td
     td
     td
        table

The last table in that list was supposed to be right align, but no modifications to it’s TD parent will change that.  You can’t use align=”right” or text-align:right.

You need to use align=”right” on the TABLE that you want to be right aligned, not on its TD parent.

I know this is a bad idea as CSS is much better for aligning elements instead of nesting tables, but in this case I’m not going to rewrite the whole app layout for 1 thing.

SQL Server Activity Monitoring

If you are using SQL Server and you want to get an overview of whats going on, you can make use of the “Activity Monitor”, which is available in Management Studio for SQL Server 2005 and later.

In Management Studio, just right click on the server (not the DB catalog) and pick Activity Monitor.

If you are using SQL Server 2000, you are in a bit of a tight spot.  Even thought the BOL say that you can use Activity Monitor from Mangement Studio, you can’t.  It’s a lie.  So you have to have Enterprise Manager installed.

From Enterprise Manager, under the server you want to view, expand the “Management” folder, and the “Crrent Activity” node.  Under there you will find Process Info, Locks/Process Id and Locks/Object.

Too bad MS didn’t make Management Studio backwards compatable like BOL claims it is.

Shrinking your SQL Server log files

Shrinking your LDFs is as easy as:

BACKUP LOG DBName WITH TRUNCATE_ONLY
ALTER DATABASE DBName SET RECOVERY SIMPLE
GO
USE DBName
GO
DBCC SHRINKFILE('DBName_log', 2)
GO

Just replace “DBName” with the actual name of the database.

In some cases you might have to inspect the properties of the database using management studio to look at the file names, if the log file happens to have a different name from dbname_log.