Wednesday, July 01, 2009

Virtual Box Seamless Mode

Just discovered Virtual Box had seamless mode. Virtual PC has a lot to catch up! The latest version with seamless mode is still in beta… Here, I’m running Fedora 11 in virtual machine, sharing the same desktop as Windows 7 RC. Cool, isn’t it?

Some minor problems though. All the Linux applications, including the panels, appear as a window on Windows, so clicking on any Linux app will bring all Linux app to the foreground. Not too nice. Resizing windows doesn’t seem to work after a while of usage.

I wish Virtual PC can play well with Virtual Box. Launching IE 6 (Virtual Window), with Virtual Box running, froze the computer, requiring a hard reset. It could have given me a warning that I shouldn’t be running 2 VMs at the same time…

Monday, June 29, 2009

LUA bug for Windows 7 XP Mode setup

There are 2 files that need to be installed for XP mode. Installation of Windows6.1-KB958559-x64.msu went OK, but VirtualWindowsXP.msi gave an error – your administrator prevented the installation.

To install correctly, I had to Shift+Right Click on the VirtualWindowsXP.msi, and click Run as a different user.

Once it is installed, clicking on Start>Programs>Windows Virtual PC>Virtual Windows XP will bring up this window.

And after some time, we’ve got XP in the virtual machine.

A differencing disk is used. If your computer has several users using XP mode, this could turn out to be a substantial saving on disk space, since only changes to the base XP image is saved in the each user’s virtual hard disk.

Tuesday, June 23, 2009

ASP.NET Label with DropDownList functions to reference another data source

I often encounter the following situation in ASP.NET when using a DetailsView to display a row that contains a reference to a table

<asp:DetailsView ID="detailsView" runat="server" AutoGenerateRows="False"

    DataSourceID="dataSource" DataKeyNames="Id">

    <Fields>

        <asp:TemplateField HeaderText="Name" SortExpression="Id">

            <EditItemTemplate>

                <asp:DropDownList ID="dropDownList" runat="server"

                    DataSourceID="referenceDataSource" DataTextField="Name" DataValueField="Id"

                    SelectedValue='<%# Bind("Id") %>' />

            </EditItemTemplate>

            <ItemTemplate>

                <asp:Label ID="label" runat="server" Text='<%# Eval(" What do I bind to here? ") %>' />

            </ItemTemplate>

        </asp:TemplateField>

    </Fields>

</asp:DetailsView>

I need the DetailsView to display in 3 modes, namely Insert, Edit and ReadOnly. For Insert and Edit modes, a DropDownList takes care of getting the values from the referenceDataSource. However, in ReadOnly mode, I do not want to introduce the DropDownList, for it would have unnecessarily bloat the ViewState and post-back values.

A label should be all that is needed to display, but what do I type to data bind the label to the referenceDataSource? Most of the time, I end up casting the Eval to a DataRowView, getting the Row, and calling GetParentRow. However, that is not a general solution that can be applied everywhere. By changing the data source to use DataReader instead of DataSet, the code in the label will break.

So I decided to roll out my own server control. Taking reference from Creating a Databound Label Control, I created a label control that takes similar attributes as DropDownList, so that all that is needed is to copy the DropDownList from the EditItemTemplate, paste it in ItemTemplate, and changing the tag to ReferenceLabel.

<asp:DetailsView ID="detailsView" runat="server" AutoGenerateRows="False"

    DataSourceID="dataSource" DataKeyNames="Id">

    <Fields>

        <asp:TemplateField HeaderText="Name" SortExpression="Id">

            <EditItemTemplate>

                <asp:DropDownList ID="dropDownList" runat="server"

                    DataSourceID="referenceDataSource" DataTextField="Name" DataValueField="Id"

                    SelectedValue='<%# Bind("Id") %>' />

            </EditItemTemplate>

            <ItemTemplate>

                <huan:ReferenceLabel ID="label" runat="server"

                    DataSourceID="referenceDataSource" DataTextField="Name" DataValueField="Id"

                    SelectedValue='<%# Bind("Id") %>' />

            </ItemTemplate>

        </asp:TemplateField>

    </Fields>

</asp:DetailsView>

Neat huh? Below is the code for the ReferenceLabel. Place it in App_Code and add the following into Web.config.

<configuration>

  <system.web>

    <pages>

      <controls>

        <add tagPrefix="huan" namespace="Huan.Web.UI.WebControls" />

      </controls>

    </pages>

  </system.web>

</configuration>

//-----------------------------------------------------------------------

// <copyright file="ReferenceLabel.cs" company="Jeow Li Huan">

// Copyright (c) Jeow Li Huan. All rights reserved.

// </copyright>

// <remarks>See <see href="http://aspnet.4guysfromrolla.com/articles/081308-1.aspx">Creating a Databound Label Control</see>

// for original implementation.</remarks>

//-----------------------------------------------------------------------

 

namespace Huan.Web.UI.WebControls

{

    using System;

    using System.Collections;

    using System.ComponentModel;

    using System.Web;

    using System.Web.UI;

    using System.Web.UI.WebControls;

 

    /// <summary>

    /// Represents a label control, which displays text referenced from another data source, on a Web page.

    /// </summary>

    [DataBindingHandler("System.Web.UI.Design.WebControls.ListControlDataBindingHandler, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]

    [ParseChildren(false)]

    [ToolboxData("<{0}:ReferenceLabel runat=\"server\" />")]

    public class ReferenceLabel : DataBoundControl

    {

        /// <summary>

        /// Gets or sets the field of the data source that provides the text content of the list items.

        /// </summary>

        /// <value>

        /// A <see cref="T:System.String"/> that specifies the field of the data source that provides the text content of the list items. The default is <see cref="F:System.String.Empty"/>.

        /// </value>

        [Category("Data")]

        [DefaultValue("")]

        [Description("The field in the data source that provides the text.")]

        [Themeable(false)]

        public virtual string DataTextField

        {

            get

            {

                return (string)this.ViewState["DataTextField"] ?? string.Empty;

            }

 

            set

            {

                this.ViewState["DataTextField"] = value;

                this.OnDataPropertyChanged();

            }

        }

 

        /// <summary>

        /// Gets or sets the formatting string used to control how data bound to the label control is displayed.

        /// </summary>

        /// <value>

        /// The formatting string for data bound to the control. The default value is <see cref="F:System.String.Empty"/>.

        /// </value>

        [Category("Data")]

        [DefaultValue("")]

        [Description("The formatting applied to the text. For example, {0:d}.")]

        [Themeable(false)]

        public virtual string DataTextFormatString

        {

            get

            {

                return (string)this.ViewState["DataTextFormatString"] ?? string.Empty;

            }

 

            set

            {

                this.ViewState["DataTextFormatString"] = value;

                this.OnDataPropertyChanged();

            }

        }

 

        /// <summary>

        /// Gets or sets the field of the data source that provides the value of each

        /// list item.

        /// </summary>

        /// <value>

        /// A <see cref="T:System.String"/> that specifies the field of the data source that provides

        /// the value of each list item. The default is <see cref="System.String.Empty"/>.</value>

        [Category("Data")]

        [DefaultValue("")]

        [Description("The field in the data source which provides the item value.")]

        [Themeable(false)]

        public string DataValueField

        {

            get { return (string)this.ViewState["DataValueField"] ?? string.Empty; }

            set { this.ViewState["DataValueField"] = value; }

        }

 

        /// <summary>

        /// Gets or sets the value of the selected item in the list control.

        /// </summary>

        /// <value>

        /// The value of the selected item in the label control. The default is an empty string ("").

        /// </value>

        [Bindable(true, BindingDirection.TwoWay)]

        [Browsable(false)]

        [DefaultValue("")]

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

        [Themeable(false)]

        public object SelectedValue

        {

            get { return this.ViewState["SelectedValue"]; }

            set { this.ViewState["SelectedValue"] = value; }

        }

 

        /// <summary>

        /// Gets or sets the identifier for a server control that the <see cref="T:Huan.Web.UI.WebControls.ReferenceLabel"/> control is associated with.

        /// </summary>

        /// <value>

        /// A string value corresponding to the <see cref="P:System.Web.UI.Control.ID"/> for a server control contained in the Web form. The default is an empty string (""), indicating that the <see cref="T:Huan.Web.UI.WebControls.ReferenceLabel"/> control is not associated with another server control.

        /// </value>

        [Category("Accessibility")]

        [DefaultValue("")]

        [Description("The ID of the control associated with the Label.")]

        [IDReferenceProperty]

        [Themeable(false), TypeConverter(typeof(AssociatedControlConverter))]

        public virtual string AssociatedControlID

        {

            get { return (string)this.ViewState["AssociatedControlID"] ?? string.Empty; }

            set { this.ViewState["AssociatedControlID"] = value; }

        }

 

        /// <summary>

        /// Gets the text content of the label.

        /// </summary>

        /// <value>

        /// The text content of the control. The default value is <see cref="System.String.Empty"/>.

        /// </value>

        [Category("Appearance")]

        [DefaultValue("")]

        [Description("The text to be shown for the label.")]

        [Localizable(true)]

        public virtual string Text

        {

            get { return (string)this.ViewState["Text"] ?? string.Empty; }

        }

 

        /// <summary>

        /// Gets the HTML tag that is used to render the label.

        /// </summary>

        /// <value>

        /// The <see cref="T:System.Web.UI.HtmlTextWriterTag"/> value used to render the label.

        /// </value>

        protected override HtmlTextWriterTag TagKey

        {

            get

            {

                if (this.AssociatedControlID.Length != 0)

                {

                    return HtmlTextWriterTag.Label;

                }

 

                return base.TagKey;

            }

        }

 

        /// <summary>

        /// When overridden in a derived class, binds data from the data source to the control.

        /// </summary>

        /// <param name="data">The <see cref="T:System.Collections.IEnumerable"/> list of data returned from a <see cref="M:System.Web.UI.WebControls.DataBoundControl.PerformSelect"/> method call.</param>

        /// <exception cref="T:System.ArgumentOutOfRangeException">

        /// The selected value is not in the list of avaliable values.

        /// </exception>

        protected override void PerformDataBinding(IEnumerable data)

        {

            base.PerformDataBinding(data);

 

            if (this.DesignMode)

            {

                this.SetText(string.IsNullOrEmpty(this.ID) ? "abc" : this.ID);

                return;

            }

 

            if (data != null && this.SelectedValue != null)

            {

                // Clear out the Text property

                this.ClearText();

 

                string formatString = this.DataTextFormatString.Length == 0 ? "{0}" : this.DataTextFormatString;

 

                // Get the DataTextFormatString field value for the FIRST record

                foreach (object obj in data)

                {

                    if (this.DesignMode)

                    {

                        this.SetText(string.Format(formatString, "Databound"));

                        return;

                    }

                    else

                    {

                        bool hasDataValueField = this.DataValueField.Length != 0;

                        object dataValue = hasDataValueField ? DataBinder.GetPropertyValue(obj, this.DataValueField) : obj;

                        if (this.SelectedValue.Equals(dataValue))

                        {

                            bool hasDataTextField = this.DataTextField.Length != 0;

                            if (hasDataTextField)

                                this.SetText(DataBinder.GetPropertyValue(obj, this.DataTextField, formatString));

                            else if (hasDataValueField)

                                this.SetText(DataBinder.GetPropertyValue(obj, this.DataValueField, formatString));

                            else

                                this.SetText(string.Format(formatString, obj.ToString()));

 

                            return;

                        }

                    }

                }

 

                throw new ArgumentOutOfRangeException("SelectedValue", string.Format("'{0}' has a SelectedValue which is invalid because it does not exist in the list of items.", this.ID));

            }

        }

 

        /// <summary>

        /// Adds HTML attributes and styles that need to be rendered to the specified <see cref="T:System.Web.UI.HtmlTextWriter"/> object.

        /// </summary>

        /// <param name="writer">An <see cref="T:System.Web.UI.HtmlTextWriter"/> that represents the output stream that renders HTML contents to the client.</param>

        protected override void AddAttributesToRender(HtmlTextWriter writer)

        {

            if (this.AssociatedControlID.Length != 0)

            {

                Control control = this.FindControl(this.AssociatedControlID);

                if (control == null && !this.DesignMode)

                    throw new HttpException(string.Format("The ReferenceLabel '{0}' cannot find associated control ID '{1}'.", this.ID, this.AssociatedControlID));

                else

                    writer.AddAttribute(HtmlTextWriterAttribute.For, control.ClientID);

            }

 

            base.AddAttributesToRender(writer);

        }

 

        /// <summary>

        /// Renders the items in the <see cref="T:System.Web.UI.WebControls.ListControl"/> control.

        /// </summary>

        /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter"/> that represents the output stream used to write content to a Web page.</param>

        protected override void RenderContents(HtmlTextWriter writer)

        {

            HttpUtility.HtmlEncode(this.Text, writer);

        }

 

        /// <summary>

        /// Sets the text in the view state.

        /// </summary>

        /// <param name="text">The text to be stored in the view state.</param>

        protected virtual void SetText(string text)

        {

            this.ViewState["Text"] = text;

        }

 

        /// <summary>

        /// Clears the text stored in the view state.

        /// </summary>

        protected virtual void ClearText()

        {

            this.ViewState.Remove("Text");

        }

    }

}

Limitations:

Due to the aim of reducing ViewState, only the initial selected text is stored in the ViewState. Changing the SelectedValue after the control has been data bound will not change the displayed text.

Sunday, June 21, 2009

10 Useful Firefox Extensions to Supercharge Firebug

I often find Firebug lacking in certain areas, such as finding where a certain html tag is used. Jacob Gube came out with a list of add ons for Firebug (which itself is a Firefox add on), that I find very useful.

Wednesday, May 20, 2009

To support long file name (>260 char), get a wider (>260 columns across) monitor

Though Windows Explorer has gotten flasher with each version of Windows, it still stumbles on the long file name that NTFS supports…

Sunday, May 17, 2009

WinForms cue/prompt/watermark/placeholder TextBox and other controls

I thought writing the placeholder text box was much easier in WPF than WinForms, since WPF allows graphical elements to be overlaid easily. I was wrong! For WinForms, a P/Invoke can achieve that function since XP and Vista had it built-in. Thanks to Aaron for the source.

Aaron Lerch » Blog Archive » Watermarked edit controls

Sunday, May 03, 2009

The “Coolest” DHTML Calendar

Searching for a JavaScript calendar returned a lot of results. However, most calendar implementations out there are buggy. They are also written in the old JavaScript ways without all the prototyping stuff, causing conflicts with my own variables and functions.

After trying out some of the calendars, I found this calendar to be the best—stable, prototyped and has few side-effects. Only worry is that it uses browser detection rather than feature detection, potentially breaking in future versions of browsers. If you know of an even better calendar, please tell me =). Thanks.

Tuesday, April 28, 2009

Start Menu - Enable Folder and Library Pin to Start Menu

Dragging the Computer link in the start menu to the Pin area creates a pin for Computer. However, while it is easy to pin, it is impossible to remove! Luckily, by just adding a new registry key, the context menu will show the “Unpin from Start Menu” item.

Instructions at Start Menu - Enable Folder and Library Pin to Start Menu - Windows 7 Forums

Thursday, April 23, 2009

Why no more 16-bit support in Windows 64-bit?

It seems kind of weird that Microsoft removed support for running 16-bit programs on 64-bit Windows. Even in Windows 7 32-bit, 16-bit programs are still supported. How different can the code be? Why is the 32-bit version written but not ported to 64-bit?

The following article explains why

Virtual 8086 mode

It is AMD and Intel who removed support for 16-bit on 64-bit. Code for 16-bit support on 32-bit must be re-written in order not to use the Virtual 8086 mode.

Does this mean that my QuickBasic programs will never see the light of the day again? Or will Windows 64-bit one day support 16-bit again (by bundling DOSBox maybe)?

Saturday, March 21, 2009

Mod your Visual Studio Professional

Here's my list of developer tools for Visual Studio Professional. Dreamspark only provides Professional Edition, so I'll be listing the

alternatives for the missing features that are only available for Team Foundation. All software listed are free unless otherwise stated.

Client-side

Code templates and refactoring

  • SlickEdit Gadgets generates methods to retrieve data from clipboard, clipboard analyzer and calculates Source Lines of Codes.
  • Enterprise Library contains various application blocks for Validation, Logging and others. (I had not used this before)
  • Coderush Xpress declare classes, interface structs, extract method and others with ease.
  • Refactor! for ASP.NET extract to user control, rename, move style to style sheets, surround with update panels and many more with ease.
    • OR
  • Coderush (Trial, best to buy as it is really worth it. For the broke, download a new version, uninstall and install when it expires). Generates templates for classes, exceptions, for/foreach loops and many more. Identifies syntax errors, suggests alternative shorter statements.  Also provides the DXCore library (free) which some of the plugins depend on. (Requires a powerful computer)
  • Refactor Pro! (Trial, best to buy as it is really worth it. For the broke, download a new version, uninstall and install when it expires). Rename, move a piece of code into a new method, extract interface, simplify logic, extract html styles to style sheets, remove end tags in XML and many more with ease. (Requires a powerful computer)

Source control (SVN)

  • Slik SVN for SVN functionalities and command line.
  • TortoiseSVN to have GUI in Windows Explorer.
  • AnkhSVN to have GUI in Visual Studio.

Code compliance/best practices

  • FxCop to check for performance, globalization, signing and other issues.
  • StyleCop to check for missing XML comments, standardize code and other issues.
  • RightHand plugin spell-check your XML comments, comments and strings. (Requires DXCore)

Database connectivity

  • NHibernate O/R mapper. Generates classes for communicating to database. Simpler and more mature than Linq to SQL. (I had not use this before)
    • OR
  • LLBLGen Pro (Buy) O/R mapper. Generates classes for communicating to database. Popular and more mature that Linq to SQL. (I had not use this before)

Unit Testing

  • xUnit.net provides method for asserting exceptions, rather than the more restrictive ExpectedException attribute used in nUnit.
  • TestDriven.Net Personal Version to have GUI in Visual Studio. (I had not use this before)

Documentation

  • GhostDoc to generate default XML comments.
  • Sandcastle to generate help files (in html/chm) from the XML comments.  (Warning: a memory and processor hog)

JavaScript tools

  • Script# generate JavaScript from C#. Native support for Windows Gadgets and Silverlight. Takes advantage of intellisense, static-typing and others of C#.
  • IE 8 for JavaScript debugging and testing IE specific methods.
  • Firefox with Firebug and Tamper Data add-ons for JavaScript debugging, testing Firefox specific methods and checking POST data.

WPF tools

  • Mole Visualizer presents your WPF classes graphically during debugging. (Warning: Crashes often the last time I used it)
  • ViewerSvg (Trial). Converts SVG into XAML.
  • Xceed DataGrid for WPF Express provides the missing data grid, masked text box, date time picker and other controls in WPF. (Warning: The last time that I’ve used it, there are some properties that you need to leave it as default, if not the data grid will crash. Test extensively.)

Regular expression tools

Reverse engineering

  • .NET Reflector reverse engineer any .NET generated dll or exe files and see the source code in C#.
  • ILDASM and ILASM (installed with VS) for editing .NET dll and exe files.
  • Spy++ (installed with VS) to find the Windows Handles of applications.

Interoperability

  • PInvoke Visual Studio Add-in provides GUI to search PInvoke.net. Community-contributed C# and VB signatures to the Windows 32 API functions.
  • Connector/NET for database connection to MySQL database (if you happen to inherit one, like me).

Blogging

  • CopySourceAsHtml copies the syntax highlighting in your C# code as html or rtf for posting/printing nicely formatted code.
  • Window Clippings (trial) for capturing screen shots with translucent non-client area (the title bar, border etc).

Server-side

Source control (SVN)

Continuous Integration

  • CruiseControl.NET check-out source code, run scripts, unit tests, source analysis whenever there is a check-in to source control. (Warning: hard to configure. I am now using it only to check-out source code)
  • NAnt run build scripts. (I had not used this before)

Bug Tracking

  • BugTracker.NET website for filing tasks, bugs. Sends email for new entries. Very easy to install and configure, though look and feel leaves much to be desired.

Friday, March 20, 2009

CSS Centering: Auto-width Margins

<div align=”center”> has been deprecated in XHTML 1.1. Replacing it with <div style=”text-align:center”> did not work.

The correct replacement is <div style=”width;1000px; margin:0 auto”> on the child element and a text-align:center on the parent element. Credit to CSS Centering: Auto-width Margins for example.

Wednesday, March 11, 2009

Windows 7 and Life Without Walls

A demonstration of web and networking functionalities in Windows 7.

RAZORTV - R.age: The Bonus Stage (Pt 2)

Saturday, January 17, 2009

Fujitsu T5010 Drivers for Windows 7 64-bit

While Fujitsu does not officially support Windows Vista or Windows 7 64-bit, there are already drivers available for most devices. Here are what I have found. Agere Systems HDA Modem - 2.1.87 http://www.versiontracker.com/dyn/moreinfo/win/163452 Wacom Penabled Tablet http://www.wacom.com/tabletpc/driver.cfm Intel GM45 Chipset INF Update Utility - Zip Format http://downloadcenter.intel.com/filter_results.aspx?strTypes=all&ProductID=816&OSFullName=Windows+Vista*+64&lang=eng&strOSs=150&submit=Go! O2Micro SD/Memory Stick Card Reader http://www.download.com/O2Micro-CardReader-xp-vista-NB-zip/3000-2122_4-185343.html ACPI Device Driver (FUJ02B1) ACPI Device Driver (FUJ02E3) Fujitsu Tablet Button Driver Fujitsu Tablet Button Utility O2Micro SmartCard Device Driver http://www.pc-ap.fujitsu.com/support/drv_lb_vis64_t4220.html Fingerprint Reader (For Windows 7 only) http://www.authentec.com/win7beta64.cfm Audio and Graphics - Intel® Graphics Media Accelerator Driver for Windows Vista* 64 (zip) http://downloadcenter.intel.com/filter_results.aspx?strTypes=all&ProductID=2991&OSFullName=Windows+Vista*+Ultimate%2C+64-bit+version&lang=eng&strOSs=162&submit=Go! http://www.download.com/Realtek-High-Definition-Audio-Codec-Windows-Vista-/3000-2120_4-10788600.html?tag=mncol Touchpad http://www.synaptics.com/support/drivers Have not found a driver that supports the Scroll Sensor beside the screen. Here's what device manager shows

Tuesday, January 06, 2009

How to recover from an accidental deletion of linux boot partition (Part 3 of 3)

Again, life didn't go so smoothly. Before resorting to using VirtualBox to recreate the files in the boot partition, I chose the Install or Upgrade option of the Fedora DVD. I tried to do an upgrade on the existing partition, namely /dev/VolGroup00/LogVol00. The installation failed with an exception thrown. Then I resorted to VirtualBox and doing everything in Part 2. Upon rebooting, all went well, GUI grub loaded, Fedora boot screen came out, and then comes the login screen. Waited. Nothing happened. Some files must have been corrupted by the failed upgrade.

Recover process

Boot into Fedora DVD. Choose the Install or Upgrade option. Upgrade the existing partition. The installation should proceed smoothly now. Fedora recovered!

How to recover from an accidental deletion of linux boot partition (Part 2 of 3)

Continuing from the previous post. Everything would have been up and running again if I had did exactly as said in the previous post. However, I did an extra step. As suggested in forums, to create a partition, I would first fdisk and then mkfs.ext3. So I went to type this instead. sda7 is the newly created partition. #fdisk /dev/sda n p 1 <enter> <enter> w #mkfs.ext3 /dev/sda7 #reboot Again the grub screen, with the kernel totally gone.

Recovery Process

Boot into Vista, install VirtualBox (VirtualPC didn't work. No USB support). All the steps below are done in VirtualBox. Create new virtual machine. Install Fedora 10. (Default installation) Boot into Fedora. swapoff -a, delete the swap partition and edit fstab. (this is to create a configuration that matches my Fedora installation on my hard disk before I deleted my boot partition) Insert thumb drive and capture it. Open Terminal. Switch to root (su). Copy everything in /boot into my thumb drive, which is mounted on /mnt/TOSHIBA Shut down Fedora. Exit out of VirtualBox. Shut down Vista. Boot into Fedora DVD. Go into Rescue Installed System. Select English, US keyboard, no network. To find which device is the thumb drive, type #blkid My system showed /dev/sdb1: LABEL="TOSHIBA" UUID=... Also, note down the UUID of the root partition, we will need it later. /dev/dm-0: UUID="<note down this long string>" TYPE="ext3" Mount the thumb drive as follows #mkdir /mnt/thumb #mount /dev/sdb1 /mnt/thumb Mount the boot partition #mkdir /mnt/boot #mount /dev/sda7 /mnt/boot Copy everything from the thumb drive to the boot partition. Next is to edit grub.conf #nano /mnt/boot/grub/grub.conf Change the timeout=0 to timeout=5 After hiddenmenu add the following to create the Windows Vista boot option.
title Windows Vista
    rootnoverify (hd0,1)
    chainloader +1
For the line beginning with kernel /vmlinuz, replace the UUID in the root=UUID=<replace this what you note down just now> To save, Ctrl+O To exit, Ctrl+X #reboot Fedora recovered!

How to recover from an accidental deletion of linux boot partition (Part 1 of 3)

Being new to Linux, I made a big mistake in deleting the boot partition. The story goes like this. A hard disk supports at most 4 partitions. I had Windows Vista and Fedora 10 installed. My system has 2 partitions taken up by the system recovery image. Windows Vista's Disk Management reports the partitions as follows 6 partitions? Hmm, I thought it could have been that the recovery partitions were special and does not take up entries in the partition table. Then I wanted to free up one partition to make (partition table) space for Windows 7 Beta 1. So Linux swap partition shall go. As I had tried out Fedora 2 long time ago, I thought the 3rd partition was Linux swap and 4th the Linux root. Booted into Linux, swapoff and edited the /etc/fstab file to exclude the swap partition. Booted back to Vista, deleted the 3rd partition. Boom! The truth revealed... I have in fact only 4 partitions! The 2 Linux partitions were on the extended partition. Rebooted my computer. All is not well... At start-up To boot into Vista, I had to type rootnoverify (hd0,1) chainloader +1 boot After looking through a number of websites, it finally dawned on me that the default Fedora partitioning had changed. The 3rd partition is a boot partition and the 4th is an LVM partition, which contains both swap and root. (both are totally new to me) No boot partition means no Fedora kernel, and that means my Fedora will never boot! Oh no!

Recovery process

Boot from the Fedora DVD. Go into Rescue Installed System. Select English, US keyboard, no network. Next step is to re-create the boot partition. #fdisk /dev/sda n p 1 <enter> <enter> w #reboot Fedora recovered!