Posted by Will on Friday, January 23, 2009 at 6:13 PM

For the application I’m currently working on I have a simple interface that I implement in all of the pages.  One of the methods is for showing feedback to the user when records are updated or input validation errors arise.  The interface looks like this simplified version:

public interface IMyPage {
    void ShowFeedback(string message, ModalMessageType messageType);
}

ModalMessageType is an enumerator:

public enum ModalMessageType {
    Success,
    Caution,
    Feedback,
    Error
}

The meat of the application’s moving parts are encapsulated in user controls which themselves implement an interface of their own.  Here is a simplified version:

public interface ISubordinateCommonView {
    IMyPage ContainingPage { get; set; }
}

As you can see the interface provides a property called ContainingPage that allows a reference to the – wait for it – page containing the user control to be passed via the Page_Load event ala

protected void Page_Load(object sender, EventArgs e) {
    MyUserControl.ContainingPage = this;
}

The modal panel is made by taking advantage of the ModalPopupExtender control from the Ajax Toolkit.  In each page at the bottom is the following markup:

<asp:UpdatePanel  UpdateMode="Conditional" ID="udpModalMessage" runat="server" >
    <ContentTemplate>
        <ajaxToolkit:ModalPopupExtender runat="server" ID="mpModalMessage"
        TargetControlID="btnHiddenModalPopupTarget"
        PopupControlID="pnlModalMessage"
        BackgroundCssClass="modalBackground"
        CancelControlID="lkbCloseModalMessage"
        />
        <asp:Panel ID="pnlModalMessage" runat="server" Style="display: none;" 
            DefaultButton="lkbCloseModalMessage">
            <asp:Timer ID="tmrTimer" runat="server" Interval="2000" Enabled="false"
                 ontick="tmrTimer_Tick" />
            <div class="divModalMessageWrapper">
                <asp:Literal ID="litMessage" runat="server" />
                <br />
                <asp:LinkButton ID="lkbCloseModalMessage" runat="server" 
                Text="Continue" OnClick="lkbCloseModalMessage_Click" />
            </div>
        </asp:Panel>
        <asp:Button ID="btnHiddenModalPopupTarget" runat="server" Style="display: none" />
    </ContentTemplate>
</asp:UpdatePanel>

Notice that the panel contains a Literal control and a LinkButton.  The LinkButton is used to cancel the modal dialog while the Literal control shows the message.  The style of the message is determined by the ModalMessageType enum value (see the CSS below).  The panel also contains a Timer control which is disabled.  In the code behind for the page are ShowFeedback method as well as the handlers for the Timer ontick event and the LinkButton click event.

public void ShowFeedback(string message, ModalMessageTypes messageType) {
    litMessage.Text = "";

    StringBuilder sb = new StringBuilder();

    //the enum vals are used to choose the css class for the div
    sb.Append("<div class=\"divModalMessage" + messageType.ToString() + "\" >");
    sb.Append(message);
    sb.Append("</div>");

    litMessage.Text = sb.ToString();

    mpModalMessage.Show();

    if (messageType == ModalMessageTypes.Error) tmrTimer.Enabled = false;
    else tmrTimer.Enabled = true;

}

protected void lkbCloseModalMessage_Click(object sender, EventArgs e) {
    mpModalMessage.Hide();
}

protected void tmrTimer_Tick(object sender, EventArgs e) {
    mpModalMessage.Hide();
    tmrTimer.Enabled = false;
}

Notice in the last two lines of the ShowFeedback method that in my particular scenario I have chosen to have all non-error message automatically dismiss themselves after two seconds.  Error messages must be canceled by the user.  Putting it all together I can have the following code in my web control:

private void UpdateSomeRecord(string s, int i) {
    try {
        //code to update the record
        ContainingPage.ShowFeedback("Record updated", ModalMessageTypes.Success);
    }
    catch (Exception ex) {
        ContainingPage.ShowFeedback(ex.Message, ModalMessageTypes.Error);
    }
}

Here’s the associated css:

.divModalMessageSuccess {
    border-width: 2px;
    border-style: solid;
    border-color: #54864E;
    color: #54864E;
    background-color: #B8D4B5;
    padding: 4px;
}    

.divModalMessageCaution {
    border-width: 2px;
    border-style: solid;
    border-color: #B19707;
    color: #B19707;
    background-color: #F8E78B;
    padding: 4px;
}

.divModalMessageFeedback {
    border-width: 2px;
    border-style: solid;
    border-color: #26588A;
    color: #26588A;    
    background-color: #B7CFE7;
    padding: 4px;
}

.divModalMessageError {
    border-width: 2px;
    border-style: solid;
    border-color: #980202;
    color: #980202;
    background-color: #F2C8C8;
    padding: 4px;
}
Comments [0]     Categories: Ajax | asp.net              
Posted by Will on Monday, January 05, 2009 at 7:22 PM

I ended up rolling back to XP on my Acer Aspire One.  The boot time was annoyingly slow, and overall the machine felt sluggish.  I made some attempts to minimize the strain by adjusting visual effects for best performance, but that did not make an appreciable difference.  None of this was unexpected.  XP is snappier with a much faster boot and more responsive operation on the whole. 

One issue that I have noticed is painfully slow wireless connectivity.  I fixed this by going into the Device Manager and opening the properties dialog for the Atheros Wireless Network Adapter.  On the Advanced tab I clicked on Power Save Mode and set the Value to "Off".  This lets the wireless connection have its fill of power while running on battery.  As I'm sure you can guess, the downside is that it does in fact use more battery power. 

Comments [2]     Categories: Equipment | Netbook              
Posted by Will on Monday, December 22, 2008 at 6:27 PM

I received my Acer Aspire One (AAO) this weekend.  As I mentioned before, the first order of business was to reload the operating system.  Loading the OS on this class of device - netbook - requires the use of a USB flash drive if you don't have access to an external CD drive.  You can find a tool called USB_MultiBoot_10 at boot-land.net.  That is the tool referenced in the how-to video I found on YouTube.  Even though I wanted to use Vista, I ran through the process as shown in the video for an XP install to familiarize myself with the procedure.  I made it through without any problems using a 4GB Corsair Flash Voyager.  Next I moved to Vista.  The USB Mulitboot tool allows this as well.  The setup is not as straightforward as XP steps without a video as a guide, but I found this post that made the process clearer.  The steps are laid out in the Aug 30 2008, 11:54 PM post by user 'wimb'.

Drivers

This table shows the drivers you'll need for the AAO:

Driver Vista Version Worked On Vista
Sound Yes Yes
Card Reader No Yes
Web Cam No Yes
Chipset Yes Yes
NIC No Alternate
Touchpad No Not extended properties
Video No Yes
WiFi No Alternate

All the XP drivers can be downloaded from the support section of the Acer site.  As shown above, the Vista drivers are included for the sound card and chipset.  The others worked anyway except for the network, both NIC and WiFi.  I found this post that showed where the Atheros WiFi drivers could be found.  The downloads were slow, but worked.  As the post says, after installing the drivers in the "Install Vista 6120 1009.zip" use the other download files to update the last errant device in the device manager.  Under XP, the touchpad software adds the ability to scroll vertically and horizontally using the edges of the touchpad.  The software will not install under Vista.  One other note: when installing the video driver I was asked whether to install it even though the currently installed version was newer.  If you encounter the same thing yourself you'll notice the version number of the one from Acer is a higher revision.  I continued with the installation.

All that's left to do now is download several hundred megabytes of updates.

Comments [0]     Categories: Equipment | Netbook              
Posted by Will on Friday, December 19, 2008 at 8:01 PM

Not that I post all that often, but I've noticed my "Off Topic" post are adding up.  Rather than continue to post non-technical entries in this blog I've created another one where I can write about the other things in which I'm interested. 

Behold the glory of the Off Topic blog.

Comments [0]     Categories: Off Topic              
Posted by Will on Thursday, December 18, 2008 at 9:29 PM

I've been wanting a netbook for use around the house to browse the web and watch television.  My wife and I made the switch to HD this past summer.  Since then we only use the television to watch movies because as bad as standard def looks on HD, what comes out of the VCR is worse.  For the few programs that we do watch - Sarah Conner Chronicles, Life, The Office, and eventually Lost and Battlestar Galactica - we catch them online via Hulu.com.  For that and Netflix a netbook looks to be just the ticket.  Also it will be a lot easier to take to China than a full size machine.

I had been pretty wound up about the Dell Mini during the late summer.  I've had a good experience with Dell for all of my work machines.  However, when I saw the specifications and price points for the Mini, not to mention what they did with the keyboard layout I turned elsewhere.  After more reading and comparisons I settled on an Acer Aspire One.  Yesterday I ordered the XP, 1GB RAM, 160GB drive, 6-cell battery version from Buy.com.  I even managed to hunt down a 5% discount coupon.

The first thing I do with any computer out of the box is reload the OS.  This of course makes sure you've rid of any bloat-ware.  The Aspire One doesn't have a CD drive so the OS install requires the creation of a bootable USB stick.  I found a video on YouTube that does a good job of guiding you through all of the steps.  I'm going to prepare the USB stick while I'm waiting for delivery of the machine.  Drivers for the Aspire One can be found on the support section of the Acer site.  I'm also going to give nLite a try.  nLite allows you to create customized installations of Windows.  According to the documentation you can integrate service packs and hotfixes and prevent the installation of unwanted components as well as integrate drivers.  I've never used it before, but this seems like a good opportunity to give it a try.

Comments [0]     Categories: Equipment | Netbook