Monthly Archives: January 2008

Automatically Remove Ads from Recorded TV with Lifextender [Featured Windows Download]Lifehacker

lifextender.png
Windows Vista only: Free, open source Vista application and Media Center plugin Lifextender removes commercials from Windows Media Center-recorded TV shows, cutting the average 30 minute show down to around 22 minutes. Lifextender scans the directory your Media Center records to, analyzes, and re-cuts the videos one at a time, then replaces the original file with the new, commercial-free one. Not only will it save you time, it’ll also save you hard drive space. If you’re using Vista’s Media Center to record TV, this is a must-have (it even works with extenders like your Xbox 360). If you aren’t using your Vista PC as a media center, maybe it’s time you turn it into the media center powerhouse it’s meant to be.




A new Linux-based media center, called Entertainer, …Lifehacker

A new Linux-based media center, called Entertainer, is now vying for your living room, and from the looks of this preview video, it’s got major potential.




4 ASP.NET AJAX JavaScript UI methods you should learn

Wrapping up my series on some of ASP.NET AJAX’s less utilized client side functionality, this post will take a closer look at some of ASP.NET AJAX’s JavaScript UI helper functions. These methods are great because they abstract away most of the tedious work that comes with supporting cross browser compatibility, leaving us with a nice, consistent API.

Specifically, I’m going to show you examples of using addCssClass, getBounds, getLocation, and setLocation to accomplish a few client side UI tasks.

Easily adding and removing CSS classes

A relatively underused feature of CSS allows you to directly apply multiple CSS classes to the same element. For example, maybe you’ve got an online test and want to style the test results to display correct answers in green and incorrect ones in red. This is one way you might do that:

.answerResult {  font-weight: bold; }
 
.correct      { color: green; }
.incorrect    { color: red; }
Answer #1: <span class="answerResult correct">correct</span>
Answer #2: <span class="answerResult incorrect">incorrect</span>

This is a clean solution to the problem. The markup is semantic and avoids repetition by splitting the highlight from the base styling. However, if we need to manipulate this on the client side, it’s going to take more work than is ideal.

Luckily, the ASP.NET AJAX client side framework provides helper functions to alleviate that complexity. DomElement’s addCssClass and removeCssClass are exactly what we need. Assuming the span was given an ID of answerResult, this is all that would be necessary to dynamically add the CSS for a correct answer:

Sys.UI.DomElement.addCssClass($get('answerResult'), 'correct');

I often use this technique in production by creating CSS classes with the same names as the status states of a field’s range of values. Then, when displaying that data, it’s trivially easy to also add some contextual styling with addCssClass.

Determining the size of an element

If you work on client side UI functionality long enough, you’re eventually going to want to determine the size of HTML elements at runtime. This turns out to be no fun at all, if you want to do it accurately cross-browser. Instead of suffering through that ordeal, you can use DomElement’s getBounds method. It returns an associative array with an element’s size and position.

For example, what if you’ve filled a GridView with an arbitrary amount of data and want to find out how tall it is? How would you go about that?

var height = Sys.UI.DomElement.getBounds($get('GridView1')).height;

It doesn’t get much easier than that, does it?

Locating and moving an element

The final methods that I want to take a look at are getLocation and setLocation. After all, the next logical step after finding the size of something is figuring out where it’s at and moving it around.

For example, let’s say you want to move a div, SomeDiv, 75px to the right:

var loc = Sys.UI.DomElement.getLocation($get('SomeDiv'));
 
Sys.UI.DomElement.setLocation($get('SomeDiv'), loc.x + 75, loc.y);

Throw it in a loop and you’ve got yourself a basic animation:

for (i = 1; i <= 75; i++)
{
  Sys.UI.DomElement.setLocation($get('SomeDiv'), loc.x + i, loc.y);
}

Conclusion

You probably aren’t going to use these functions as often as $addHandler or the base type extensions. However, when you do need them you’re going to be really glad you know about them. They save a lot of work, and help to automatically ensure a level of cross browser compatibility that is tedious to constantly write from scratch.

###

Originally posted at Encosia.com. If you’re reading this on another site, come on over and take a look at the real thing.

4 ASP.NET AJAX JavaScript UI methods you should learn

Desktop Newsreaders FeedDemon and NetNewsWire Now Free [Featured Download]Lifehacker

freegator.png
Windows and Mac OS X only: If you’ve ever considered using a desktop-based newsreader rather than online options like Google Reader, chances are you’ve run into NewsGator’s FeedDemon (Windows) or NetNewsWire (Mac). Today NewsGator has announced that both offerings are free, meaning that you can now get the speed, desktop integration, smart lists, and syncing capabilities of these awesome newsreaders for the wonderful price of naught. I made the move to NetNewsWire from Google Reader a couple of months back, and frankly, I’m not sure I could go back to web-based RSS. Now that both FeedDemon and NetNewsWire have hit the freeware world, I don’t think I’ll ever have to. They’ve also freed up NewsGator Go! (for Windows Mobile) and NewsGator Inbox (for MS Outlook). Awesome.




Free PDF to Word Doc Converter Is Exactly That [Featured Windows Download]Lifehacker

pdftoword_cropped.jpg
Windows only: There are many, many tools to convert Microsoft Word files into PDF documents, including those built into the latest office suites, but what about the other way around? Free PDF to Word Doc Converter is a small program that solves a big headache for some office and document workers. Load up a PDF, choose how you want to export the file—including images, shapes, and text layout functions—and hit the convert button. My own tests found, like others, that some pretty big Word files can come out, especially if you've got images and graphs embedded, but for your standard text-only document, the free tool gets most of the text and layout right. Free PDF to Word Converter is a free download for all versions of Windows.




ASP.NET: Text data from database table gets encoded twice

I had a table with data stored in a UTF-8 format. Such data gets encoded twice when it is displayed on ASP.NET page, for example for “’” I see something like this “’”.

To solve this problem I added handler to translate the table data:

text = Encoding.UTF8.GetString( System.Text.Encoding.Default.GetBytes(text) );

WP Like Button Plugin by Free WordPress Templates