Archive for October, 2008

Fixing Windows Delayed Write Failed error

Recently, while copying data from one USB external drive to another, I got the following error:

Windows – Delayed Write Failed : Windows was unable to save all the data for the file F:\$Mft. The data has been lost. This error may be caused by a failure of your computer hardware or network connection. Please try to save this file elsewhere

What appears to be happening is that the USB can’t keep up with the disk writes and is timing out. The error is puzzling since I do not have write cache enabled.  Both usb hard disk were set up for quick removal. In any case, the result is bad. The hard disk becomes corrupted.

There are a variety of possible causes to this problem. Microsoft listed various hotfix for this issue, but they were for SP2, so those fixes should have been rolled into SP3 by now. I tried to isolate the problem by using the same hard disk setup on a different machine. The copy worked flawlessly on a different machine. I figured it was most likely to be driver related. However, I have the latest driver from the manufacturer, right?

Wrong, the motherboard is a few years old and the drivers are from a few years ago. Since then Microsoft has updated XP by SP2 and SP3. Because the manufacturer no longer sell that board, they didn’t bothered to update the drivers. I poked around the Device Manager and discovered that the chipset is VIA. I then use google to locate a driver for the VIA chipset release recently in Oct 2008 that works for all VIA chipset. I installed it and the problem went away.

While I can’t guarantee that this will correct your problem, it’s worth a try to see if it will work. Try to see if there is a newer driver from the motherboard and chipset manufacturer.

As for the corrupted drive, you may be able to recover the data by copying as much data as possible, delete the partition, add a new one, format and put the data back. In my case, I had a back up so I erase the drive and repopulated it from the data.

Morale of the story

  • Be careful when you upgrade your OS, it’s possible that when you install a new Service Pack, your drivers may need updating.
  • You may not be able to depend on your vendor to provide a compatible driver. You may have to do some digging and find out the new driver from the chipset manufacturer and install it yourself.
Advertisements

October 28, 2008 at 7:18 am 1 comment

A simple introduction to ASP.Net validators

When I first started using validators in ASP.Net, I was confused by the documentation. This article is intended to be a very simple introduction to validators in ASP.Net.

What is a Validator
A validator checks the input of a control to verify that the value falls within criteria you specified. If we create a simple web site with the following code:

A simple Validator
The following is an default.aspx file.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Validator Introduction</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="NumberLabel" runat="server" Text="Number" />
        <asp:TextBox ID="NumberTextBox" runat="server" />
        <asp:Button ID="submitbutton" runat="server" Text="submit" />
    </div>
    </form>
</body>
</html>

All this is a text box with a submit button. It would be nice to make sure that the user enter a valid number. To do this, we’ll add a validator to check that it is a number.

    <div>
        <asp:Label ID="NumberLabel" runat="server" Text="Number" />
        <asp:TextBox ID="NumberTextBox" runat="server" />

        <asp:RangeValidator ID="NumberRangeValidator"
            runat="server" ErrorMessage="Input must be in the range of 1-10"
            ControlToValidate="NumberTextBox" MaximumValue="10" MinimumValue="1"
            Type="Integer" EnableViewState="false" Display="Dynamic">*</asp:RangeValidator>
        <asp:Button ID="submitbutton" runat="server" Text="submit" />
    </div>

The validator we added is a range validator. On this validator, we have set the following:

  • ControlToValidate the ID of the control you are validating.
  • The MininumValue and MaximumValue sets the range you want the input to be in.
  • The Type is set to Integer.
  • ErrorMessage is the error message to be displayed when validation fails
  • Display is set to Dynamic because it will otherwise take up the space of the error message.
  • EnableViewState is set to false since there is no reason to store viewstate for an validator.

When you hit submit and you enter a text value or a value that does not fall into 1-10, a red error text appear next to the control.

The problem is when you enter a blank value and hit submit, no error is display even though a blank value is not in the range 1-10.

Handling blank values

One issue to watch out for is that virtually all of the validators will not validate if the value is set to blank. This is why the range validator failed to catch the blank input even though a blank is not in the range of 1-10.

To get around the problem, we have to use the required validator in conjunction with your value validator. The required validator basically checks that you entered something.

    <div>
        <asp:Label ID="NumberLabel" runat="server" Text="Number" />
        <asp:TextBox ID="NumberTextBox" runat="server" />
        <asp:RangeValidator ID="NumberRangeValidator"
            runat="server" ErrorMessage="Input must be in the range of 1-10"
            ControlToValidate="NumberTextBox" MaximumValue="10" MinimumValue="1"
            Type="Integer" EnableViewState="false" Display="Dynamic">*</asp:RangeValidator>
        <asp:RequiredFieldValidator ID="NumberRequiredValiator" runat="server"
            ControlToValidate="NumberTextBox" ErrorMessage="Number field cannot be blank."
            EnableViewState="false" Display="Dynamic">*</asp:RequiredFieldValidator>
        <asp:Button ID="submitbutton" runat="server" Text="submit" />
    </div>

Now when you enter a blank input, the required validator will prompt the user to enter a value

Using a Validation Summary to group error message together
One problem you’ll notice is that the error message takes up space whether it is displayed or not. We will next get around the issue by creating a validation summary to group all of the error messages in one spot. To mark which field we need to fix, we’ll add a “*” to the field that failed validation.

    <div>
        <asp:ValidationSummary ID="ValidationSummary" runat="server" />
        <asp:Label ID="NumberLabel" runat="server" Text="Number" />
        <asp:TextBox ID="NumberTextBox" runat="server" />
        <asp:RangeValidator ID="NumberRangeValidator"
            runat="server" ErrorMessage="Input must be in the range of 1-10"
            ControlToValidate="NumberTextBox" MaximumValue="10" MinimumValue="1"
            Type="Integer" EnableViewState="false" Display="Dynamic">*</asp:RangeValidator>
        <asp:RequiredFieldValidator ID="NumberRequiredValiator" runat="server"
            ControlToValidate="NumberTextBox" ErrorMessage="Number field cannot be blank."
            EnableViewState="false" Display="Dynamic">*</asp:RequiredFieldValidator>
        <asp:Button ID="submitbutton" runat="server" Text="submit" />
    </div>

Now whenever we get a validation error, all of the validation errors appear in the validation summary area. In addition, a red “*” appears next to the field that requires correction.

Using Validation Group to control what is validated

Starting in ASP.Net 2.0, it becomes possible to control what is validated when you submit. This allows you to have multiple submit button on the same page. When you click on the submit, only part of the page is validated.

The multiple submits are controlled by validation groups. Suppose you have a page that has address and credit card, you can group all of the address validation under the group “address” and the credit card under the group “creditCard”. When you press the check credit card button, only the credit card number field is validated.

Validation group is a field in the controls.

        <asp:TextBox ID="Address" runat="server" ValidationGroup="address" />
        <asp:Button ID="AddressSubmit" runat="server" Text="Submit Address" ValidationGroup="address"/>
        <asp:TextBox ID="creditCardNumber" runat="server" ValidationGroup="creditCard" />
        <asp:Button ID="CCSubmit" runat="server" Text="Submit Credit Card" ValidationGroup="creditCard"/>

In your click event, you can add the code “if (Page.IsValid)” in your click event handler. This will cause a validation on the control in the same validation group that the event handler is attached to. In the above set of controls, pressing CCSubmit will cause validatoin on the creditCardNumber textbox.

October 19, 2008 at 5:04 pm 2 comments

Switching to the Open source Athero driver after Mandriva 2009 upgrade

Mandriva 2009 comes with a new open source Athero driver, but because I upgraded rather than reinstall, it was still stuck on the old madwifi driver. Here’s what I did to get rid of it and switch to the new driver.

  1. Install and Remove software and type in madwifi to search for all instances of madwifi. Uninstall all instances of madwifi.
  2. Reboot the laptop.
  3. For some reason, it doesn’t automatically detect the athero. I opened up a command line, login as root and typed:modprobe ath5k

The laptop should now be on the new open source driver from now on. You may need to re-enter your wireless configurations.

October 12, 2008 at 11:29 am 1 comment


Calendar

October 2008
M T W T F S S
« Sep   Nov »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Posts by Month

Posts by Category