English 中文(简体)
ASP.NET Ajax ReOrderList - Any way to disable specific items from being dragged and dropped?
原标题:

I have an ajax controltoolkit reorderlist within an asp.net application.

I need to disable certain specific steps from being reordered. This has to be done dynamically. All steps are consecutive and start from the beginning, but it s not known until runtime how many need to be disabled from being reordered any further.

I tried the e.item.enabled = false for reorderlist_itemdatabound but this just disabled links. I need to disable the drag handler.

Any help is greatly appreciated. Thanks!

最佳回答

To be honest, I m not too familiar with this control, but...

You need to hide the drag handler div (or whatever is in the DragHandleTemplate I believe) and/or change its class. Two suggestions:

1) Add a javascript startup script to disable the divs in question.

2) Subclass this control... Override the Render() method. Replace it with original code from ReorderList, but check the Item to see if you should render the drag handle.

问题回答

as a workaround to disable drag n drop for some item - you can set width=0 to the control inside

 <DragHandleTemplate> </DragHandleTemplate>
. Thus user won t be able to pick the item for dragging.

Suppose you have an image with id dragme in DragHandleTemplate; you can do this in the ItemDataBound handler:

Image dragMe = (Image)((TableRow)e.Item.Controls[0].Controls[0]).Cells[0].Controls[0].FindControl("dragMe");

dragMe.Style.Add(HtmlTextWriterStyle.Visibility, "hidden");

This way you preserve the alignment.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签