Zhi-QiangNi's tech blog--AJAX's paradise
I'm working at the Microsoft IBS DevDiv Community Support Team, in charge of the customer service of ASP/AJAX forum. Welcome to my blog and AJAX forum, anyone interested in ASP.Net Ajax can discuss it with me. :-)

Preface

ReorderList is an ASP.NET AJAX control that implements a bulleted, data-bound list with items that can be reordered interactively. To reorder the items in the list, the user simply drags the item's control bar to its new location. Graphical feedback is shown where the item will be placed as it is dragged by the user. The data source is updated after the item is dropped in its new location.

Sometimes we may need to handle the drag event to change the dragged item's style or popup some message after dropping it to a new location. Firstly, let's dig into the design code to find some useful handlers or events.

Background 

Code

Scenario

Here is a scenario. One customer placed a Command Button inside the ItemTemplate, then he can execute some operation in the server side command event. His target was to changing the selected item's style to specify it when clicking on the command button.

We need to split this goal into points:

  1. As the events of ReorderList are client side events, we need to change the style at client side.
  2. The ReorderList creates the DragVisual based on the dragged item including the style, so, we have to recover the original style of the items before dragging or after dropping.
  3. The command button would make a post back after clicking on it, so, we have to cache the selected item's index in the cookie, then, changing the style after page's reload at client side.

Code

Here is my detail code of this solution:

Code

 

Note

This is only a particular sample to handle the drag/drop event. You can modify it based on your own request. Feel free to discuss this UI with me here or in the ASP.NET Ajax Forum.

The related thread url: http://forums.asp.net/t/1380407.aspx

posted on 2009-02-12 12:35  Zhi-Qiang Ni  阅读(1724)  评论(5编辑  收藏  举报