Monday, February 25, 2008

better Tool Tips

By using only CSS, there is a cool trick that replaces the built-in Tool Tip that pops up when you hover over a link. Usually, the value of the title attribute is displayed as text-only in an ugly box.

Here's the CSS


/** css tooltips */
a.tip {
border-bottom: 1px dashed;
text-decoration: none;
}

a.tip:hover {
position: relative;
cursor: help;
}

a.tip span {
display: none;
}

a.tip:hover span {

display: block;
position: absolute; top: 10px; left: 0;

/* formatting only styles */
padding: 5px; margin: 10px; z-index: 100;
color:#000;
border: 1px dotted #c0c0c0;
text-decoration: none;
padding-right: 20px;
background: #f0f0f0 url(images/status-info.png) 100% 5% no-repeat;
filter:alpha(opacity=90);
-moz-opacity:.90;
opacity:.90;
/* background-color:#f0f0f0; */
width: 325px;
/* end formatting */
}
a.tip:hover span li {
list-style:none;
}
a.tip:hover table th
{
font-weight:bold;
text-align:right;
vertical-align:top;
}



And here is how you implement it in the HTML code. Any text (or HTML markup) between the tag appears in the pop-up box. This isn't actually a pop-up window, so it shouldn't be blocked by pop-up blockers.


My Displayed TextMy hidden tooltip text

Thursday, February 21, 2008

Selecting an index in a DropDownList

VB.Net


DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue())

'DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByText())


I post this because I can never remember how to do this simple thing (happens a lot these days...)

Wednesday, February 13, 2008

Calculating date differences in T-SQL

In the past, I always used custom functions to calculate the differences between dates in MS-SQL (T-SQL) when I wanted the date part to be months or years. I came across a very simple way of doing it without a stored function call.

select dateadd(dd, -15,getdate())

Simple, huh?

The date part can be dd (day), mm (month) or yy (year). The next argument is the number of date parts to add or subtract. The third argument is the original date we are calculating the difference from. In the above example, we are using the getdate() function to use the current date and time.