peter

peter

  • NA
  • 320
  • 0

Drag and Drop in ASP.Net

Jun 30 2022 11:28 PM

I want to get the value of label LabRef and pass to Ajax function for processing. At moment i am retrieving value of hidden field from draggable div inside Repeater control but now need to pass the label value also.

function OnDragStart(e) {

    e.dataTransfer.effectAllowed = 'move';

    e.dataTransfer.setData('text', $(this).find('HiddenField[ID*="HiddenField1"]'));
}
function OnDrop(e) {
  

 $(this).append("<div class='selectedproduct' data-product-name='" + e.dataTransfer.getData('text') + "'>" + e.dataTransfer.getData('text') + "</div>");

        var data = new Array(1);
        $("#img1 div").each(function (index) {
            data[index] = "'" + this.innerHTML + "'";

        });

        function sendMyAjax(URL_address) {
            $.ajax({
                type: 'POST',
            
                url: URL_address,
                contentType: "application/json; charset=utf-8",
                data: '{products:[' + data.join() + ']}',
                dataType: 'json',
                success: function (results) { alert(results.d); },
                error: function () { alert('error'); }
            }); return false;
        };

}

<ItemTemplate>
    <tr  class="w3" id="trID" runat="server" >
        <td>
            <asp:CheckBox ID="chkDeleted" runat="server" Text=""></asp:CheckBox>
        </td>
        <td>
            <div draggable="true" id="lnk">
            <asp:HiddenField ID="HiddenField1" runat="server" Value='<%#DataBinder.Eval(Container, "DataItem.InboxID")%>' />
            <asp:LinkButton ID="LinkButton1" CommandName="Message"  style="width:400px;white-space: normal;" CommandArgument='<%#DataBinder.Eval(Container, "DataItem.InboxID")%>' Text='<%#DataBinder.Eval(Container, "DataItem.Subject")%>' runat="server"></asp:LinkButton>
            </div>
        </td>
        <td>
            <asp:Label ID="Label1" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Datentime", "{0:g}")%>'></asp:Label>
        </td>
        <td>
            <asp:Label ID="LabRef" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.MessageType")%>'></asp:Label>
        </td>              
    </tr>
</ItemTemplate>

 


Answers (2)