DayPilot Forums

DayPilot is the best open-source Outlook-like calendar control for ASP.NET.
DayPilot Pro Demo (Calendar control)
» DayPilot Pro live demo (Calendar control)
DayPilot Pro Demo (Scheduler control)
» DayPilot Pro live demo (Scheduler control)
Home » How To » Drag and Drop from a TextBox or Grid

Drag and Drop from a TextBox or Grid

Dear Dan!

I'm trying to drag a text from a Textbox or Grid cell to the Calendar:

<asp:TextBox ID=TextBox1 runat="server" onmousedown='return DayPilotCalendar.dragStart(this.Text, 60*30, "123", this.Text);'></asp:TextBox>

EventMove is invoked correctly, e.value, e.NewStart, e.NewEnd is OK, but e.Text is empty. Can you help me how to pass the text from the TextBox?

Thank you in advance.

Anonymous - 11/30/2007 4:27:18 PM

I would really like to drag and drop arow from a GridView. Can you please help me, how can I implement it?

Thank you

Anonymous - 12/3/2007 8:50:20 AM
TextBox

As mentioned here (Drag&drop from an external source) the last parameter of dragStart() specifies the event text. You should modify your onmousedown attribute as follows:

onmousedown='return DayPilotCalendar.dragStart(this, 60*30, "123", this.value);'
If you want the TextBox to be removed after drop, keep the first "this", otherwise replace it with "null" (without quotes). "this.value" refers to the value of <input> element (that's the resulting HTML of TextBox).

GridView cell
To be able to drag from a GridView, you should use a TemplateField to render custom HTML. One of the ways to do it is here:

<asp:TemplateField HeaderText="Item">
<ItemTemplate>
<div onmousedown='return DayPilotCalendar.dragStart(this, <%# Eval("DURATIONINSEC") %>, <%# Eval("ID") %>, <%# Eval("TEXT") %>);'>
<asp:Label ID="LabelItem" runat="server" Text='<%# Eval("TEXT") %>'></asp:Label></div>
</ItemTemplate>
</asp:TemplateField>
There might be some typos, especially in the double/single quotes combination, but you should get the idea. Let me know if there is any problem with this solution.
Dan Letecky - 12/3/2007 10:28:57 AM

Dear Dan!

Thank you very much for your quick and detailed answer. The only modification I had to do was adding double quotes to get the ID of the selected row in GridView:

onmousedown='return DayPilotCalendar.dragStart(null, 60*30, "<%# Eval("ID") %>", "" %>);'

I have an other problem: When dragging from the grid, everything becomes selected that is passed by the item beeing moved. I also send this message to you by e-mail attaching the screenshot. Do you have any idea how can I solve this problem?

Anonymous - 12/4/2007 1:43:37 PM
The selecting issue is fixed in the current code (it will be included in the next release).

A workaround is to add unselectable='on' attribute to all child elements of the element with onmousedown specified.
Dan Letecky - 12/7/2007 12:25:03 AM
Post reply