Wednesday, March 31, 2010

ReorderList in AJAX .NET Control Toolkit Requires ClientIDMode="AutoID"

When using "ReorderList" from AJAX .NET Control Toolkit, I found that it has a "hidden requirement": its "clientIDMode" attribute must be set to AutoID.

If you look at the AJAX .NET Control Toolkit sample website, its ReorderList sample does not have this attribute set. But the ReorderList sample works fine. How is that possible? It is because this sample site has "clientIDMode="AutoID" set in its web.config file:


<system.web>

...

<pages ... clientidmode="AutoID">

...

</system.web>


In other words, all controls in this sample website have this attribute set automatically!

What happens if you do not have this attribute set on a ReorderList control? Well, you will not be able to drap and drop items to reorder them. If you look at the HTML code that is generated, the "_behavior" attributes that are supposed to go to each "li" element in the item list all get piled onto a single "div" element on the outside, along with the "DraggableListItem" attribute. So when you try to drag an item in the list, you will either get no response, or a stop-sign icon.

2 comments:

  1. I banged my head against this problem for a while, and then figured out the same thing you did. Afterward, I googled ReorderList AutoID and your post came up, which could have saved me a lot of time if I had found it first.

    Do you mind if I post this on stackoverflow? Or would you like to post it yourself?

    ReplyDelete
    Replies
    1. Thanks Matthew. Please go ahead and post it to stackoverflow. I need to get familiar with the process of posting in stackoverflow, and I just have not found the time to do it yet.

      Delete