Blog

Excellent Reading Material – MSMQ, WCF, and IIS

August 21, 2008 by Damien White

If you are working with a WCF service, an MSMQ binding, and hosting in IIS, there are three wonderful articles by Tom Hollander that you should check out. The series is entitled “MSMQ, WCF and IIS: Getting them to play nice”, here are the three links:

They sure have helped me get one of my projects working, and I’m sure they will help you as well.

ObjectDataSource, SOA Style

August 18, 2008 by Dave Marini

It’s been entirely too long since my last post, and with the olympics in full swing, we’ll go with a volleyball theme for this post.

BUMP

So here’s the scenario. After really digging your teeth into ASP.NET 2.0 and playing around wiih all the cool data access features, you decide to apply a liberal use of the ObjectDataSource for its ability to take care of the paging and sorting calls for you. Now, you begin to convert your site to a service oriented back end and you wonder how you’re going to make calls against your web service. You have a few options in front of you. You can create a thin facade layer that will act as a liaison between your presentation code and your service layer calls, and hook your ObjectDataSource to that. This works especially well when you have a complex object model that makes use of the web service calls behind the scenes. It’s also beneficial when you are generating your proxy classes from metadata or contacting a foreign web service. In the scenario I’m going to demonstrate here, I’m referencing a shared contract and service library, so I’ll be using using the ObjectDataSource to make direct calls to ChannelFactory for this example. Read More »

Dynamic AJAX Control Toolkit – ValidatorCallout Extender

July 24, 2008 by Damien White

I added one of these a while ago and figured I would include another. Dynamic AJAX Toolkit Controls seem to really be an issue for some, so I hope this helps. This time, we will create a dynamic ValidatorCallout for a TextBox with a RequiredFieldValidator (although you can use any validation method). One other thing to note on the ValidatorCallout is that  it only works with client-side validation.
Read More »

Dynamic Control ViewState Problems

July 23, 2008 by Damien White

The ID Property is Important

I’ve encountered quite a few developers having ViewState problems with dynamic controls. Ever have a control get recreated, but the value isn’t there on PostBack and you are creating your controls at the correct time? Frustrating to say the least. Anyway, even if you follow the correct pattern for creating / recreating dynamic controls, you may either forget (D’oh) or don’t set (Double D’oh) an ID for the control. By not setting an ID, you are relying on ASP.NET to create the control with the same ID. Sometimes it will, other times it won’t… not a gamble you should take. Read More »

AJAX Control Toolkit – DropDownExtender Always Visible

June 12, 2008 by Damien White

Dropdown Today I came across a problem of making the DropDownExtender appear as if it is a standard drop down like it is when you hover over it (as shown in the image to the right). Initially I was thinking you could do something with the Animation framework, but after a bit of research I found the way to do it. This forum post (look for the accept answer by KristoferA), has the solution. The source code below the full working solution. Read More »

AJAX Control Toolkit – Layout Problems

June 11, 2008 by Damien White

A real common problem with using the AJAX Control Toolkit revolves around the rendering of the controls. Taking an example from the ASP.NET Forums, let’s say you have a Tab Control on your page. Everything looks ok, and then you run it. You notice that there is a weird space towards the bottom of one of your tabs. D’oh! What could be wrong? Well, in general, usually the cause of these types of problems are related to one of two issues, Quirks Mode or CSS conflicts. In the ASP.NET Forum example above, it was a Quirks Mode issue. Read More »

Wrox Blox – ASP.NET AJAX Control Development with Visual Studio 2008 and .NET 3.5 Framework

April 28, 2008 by Damien White

ASP.NET AJAX Control Development with Visual Studio 2008 and .NET 3.5 Framework Wrox Blox

I’m happy to announce that my second Wrox Blox is done and available for purchase as of today! As you may remember, back in January, my first Wrox Blox on the ASP.NET AJAX Control Toolkit was released. Now, continuing with the ASP.NET AJAX theme, the new Wrox Blox deals with creating your own ASP.NET AJAX controls, from scratch. As you may or may not know, control development is one of my favorite topics. There are always times when you create something that you and others will useful in multiple applications, and these cases usually are good candidates for a server control. This book takes the “Server Control” to the next level by enabling a rich client interface with ASP.NET AJAX. If you are still working in VS 2005, don’t let the title scare you away. Even though the book focuses on VS 2008 and .NET 3.5, you’ll still find the code and concepts apply within VS 2005 with .NET 2.0 and ASP.NET AJAX Extensions 1.0. Read More »

Building A Better FindControl

April 03, 2008 by Damien White

I’ve come across a lot of times when I wish I could just use the standard FindControl method on a Page or on a container control and have it be found without having to make sure that the control was a direct child of my current container. Also, I wish I could find all controls of a particular type on a page. Why couldn’t the Control class be given these gems out of the box? Well, thanks to extension methods, custom iterators and a dash of linq, I’ve built my own Control Finding mechanism that gives a broader search and adds some type safety to the mix.

Read More »

Great TV – Download: The True Story of the Internet

April 02, 2008 by Damien White

I just wanted to drop a quick note to let everybody know about a great show I caught two episodes of on the Science Channel. It is called “Download: The True Story of the Internet”. I watched the episode “Bubble”, which discusses the .COM bubble, it also focuses on Amazon.com and EBay.com, as they are two companies that made it through the .COM bust and changed the way we do business. I also caught the episode titled “People Power”. This episode talks about how there is a new breed of sites out there that empower the user. This ranges from Napster to MySpace, YouTube, Facebook, etc. There are two other episodes listed in the Science Channel’s schedule for the show that I’m looking forward to, “Browser Wars” and “Search”. Last I checked, you can catch all four episodes on April 5th and 6th. I highly recommend checking them out.

It should be noted that sadly, as of this writing, Discovery/Science Channel doesn’t have “Download” available for download on the Internet.

ASP.NET AJAX Control Development and the Chatty onMouseOut Event

March 24, 2008 by Damien White

If you have been working on developing ASP.NET AJAX web controls, there is a good chance that you may have encountered some issues with the onMouseOut event. The issue comes about when you are developing a container-type control (e.g. a Panel or DIV) and you wish to capture the mouse out event on the parent container. A container control contains children, and what ends up happening is when you move your mouse around the control, you’ll find that onMouseOut fires for the parent even though the mouse hasn’t left the container. The problem is due to event bubbling. This probably isn’t anything too new for you if you have done a lot of JavaScript and there are solutions on the Internet that discuss this issue. However, in an ASP.NET AJAX Control, the process is similar to the straight JavaScript equivalent, but there are some changes to be aware of.

The solution involves performing a test on the element that the mouse is now on. The element can be retrieved using the relatedTarget in FireFox or toElement in Internet Explorer. Once we have the element, we will make sure that it isn’t the element itself or a child of the element. Remember, we only want to fire the onMouseOut event when the mouse has fully left the parent. The setup here is that you have an ASP.NET AJAX Control that has a method named _onMouseOut where you have already created the handler and such for it. If you aren’t familiar with this, I would recommend checking out the ASP.NET AJAX Documentation under the ASP.NET AJAX Extensibility section, specifically, a good example is this one, which illustrates using the IScriptControl.

The Solution

_onMouseOut : function(e) {
    /// <summary>
    /// Handler for the Control's mouseout event
    /// </summary>
    /// <param name="e" type="Sys.UI.DomEvent">
    /// Event info
    /// </param>

    // Access the raw event since we need the relatedTarget/toElement
    var ev = e.rawEvent;

    // Access the DomElement; this is the parent we will be testing
    var parent = this.get_element();

    // Access the element the mouse is now over
    // relatedTarget = FireFox; toElement = IE
    var rel = (ev.relatedTarget) ? ev.relatedTarget : ev.toElement;

    // Ensure the mouse isn't still over the control
    // And make sure the mouse isn't over a child of the control
    if (parent != rel && !this._isChild(parent, rel)) {
        // TODO: Handle OnMouseOut
    }
},
// Helper Methods
_isChild : function(parent, child) {
    /// <summary>
    /// Helper method to determine if an element is a child of a parent DomElement
    /// </summary>
    /// <param name="parent" type="Sys.UI.DomElement">
    /// The parent element
    /// </param>
    /// <param name="child" type="Sys.UI.DomElement">
    /// The element to check if it is a child of the parent
    /// </param>

    // Make sure that the child node isn't null
    if (child != null) {

        // While the child still has a parent node
        while(child.parentNode) {
            // Move up the chain of parents
            child = child.parentNode;

            // Test if the test parent element is in the chain
            if(child == parent)
                return true;
        }
    }
    // Element isn't a child of the parent
    return false;
}

I have added inline comments to make the code self-explanatory, I feel it is pretty straightforward to understand. In addition to the _onMouseOut method, you can see I also added a helper method to test if an element is a child of a parent element. You can trim these down into a single function if you’d like. The one thing that you may find confusing is accessing the rawEvent. Note that the event argument passed in an ASP.NET AJAX Control is of the type Sys.UI.DomEvent, not the native DOM event, so hence the rawEvent property, which exposes this. The DomEvent contains this property even though it isn’t listed in the ASP.NET AJAX Documentation as of this writing.

I came up with this technique after doing some research on the Internet and came across this post on the CodeHead forums as well as this one on QuirksMode.org. Using these ideas, I tweaked them to get them to work within the context of an ASP.NET AJAX Control.