March 2012 Entries

How to create Checkboxes that act like Radio buttons with Jquery
I have a post here to show code examples for check/uncheck all checkbox with Jquery. This time I will implement another request that the user should only be able to check at most one of the checkboxes, it's behave like radio buttons. There are 2 cases. Case 1 shows function that has little difference with radio button. It allows the user to deselect checkbox. Case 2 is same as radio button. Case 1 <head id="Head1" runat="server"> <title></title> <script src="Scripts/jquery-1.4.1.m... ......

Posted On Thursday, March 22, 2012 1:22 PM | Comments (0)

Replace broken image with noimage icon using Jquery
Sometimes when the image isn't available on server, the web page will show a broken image. so we can display a "no image available" image for good user experience. I will implement it using Jquery. $(document).ready(function() { $("img").error(function() { $(this).hide(); }) .attr("src", "noimage.jpg"); }); Please note that we must first hide the broken image, or else even if we set the src to noimage, it still can not show noimage icon ......

Posted On Tuesday, March 20, 2012 7:23 PM | Comments (0)

The device is not ready
When you retrieve the drive info using the DriveInfo class, if you don't use the IsReady property to test whether a drive is ready, it will throw error as "The device is not ready". so you must use IsReady property to determines if the drive is ready to be queried, written to, or read from. The following code example demonstrates querying information for all drives on current system. using System; using System.IO; class Test { public static void Main() { DriveInfo[] allDrives = DriveInfo.GetDrives(); ......

Posted On Sunday, March 18, 2012 6:16 PM | Comments (0)

How to download files using a Generic Handler
Using a Generic Handler to download files from server has couple of advantages, I list some of them: 1. Download Statistics. 2. Download Tracking. 3. Download Protection. 4. Other business request. So I suggest that you always use Generic Handler to download files from server. Here I will show how to implement it. 1. Add Generic Handler and name it to “Download.ashx”. 2. Add code to the download handler public class Download : IHttpHandler { public void ProcessRequest(HttpContext context) { //add ......

Posted On Wednesday, March 7, 2012 8:42 PM | Comments (4)