Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello guys. I help some help here(badly)!
So i have a drag and drop datalist
item, and it can be drop into another div and display in text.
So here's my question how do i send this text into my database(i'm using rest service here)

THANKS IN ADVANCE!!!!!

My html code : (client)

C#
asp:DataList ID="DataList1" runat="server" DataKeyField="FoodID" RepeatDirection="Horizontal" RepeatColumns="3" >
    <ItemTemplate>
         <div id="div1" class="block">

        <asp:Label ID="FoodIDLabel" runat="server" Text='<%# Eval("FoodID") %>' Visible="False" />
        <br />
        <asp:Label ID="FoodNameLabel" runat="server" Text='<%# Eval("FoodName") %>' />
        <br />
        Calories:
        <asp:Label ID="CaloriesLabel" runat="server" Text='<%# Eval("Calories") %>' />
        <br />
        image:
        <asp:Image ID="Image1" runat="server" />
        <br />
<br /></div>
    </ItemTemplate>
    </asp:DataList>

     <div id="div2" class="drop">Drag Food To Here<br />
         <br />
         </div>


C#
<script language="javascript" type="text/javascript">


        window.Error = function (msg) {
            alert(msg);
        }


JavaScript :
        $(document).ready(function () {

            $(".block").draggable({ helper: 'clone' });


            $(".drop").droppable({
                accept: ".block",
                activeClass: 'droppable-active',
                hoverClass: 'droppable-hover',
                drop: function (ev, ui) {
                    $("<div></div>").text(ui.draggable.text()).appendTo(this);
                    this.value = $(ui.draggable).text();

                }
            });
        });




Lastly my rest service for create : (.cs)
C#
[OperationContract]
       [WebGet(BodyStyle = WebMessageBodyStyle.Bare,
           RequestFormat = WebMessageFormat.Json,
           ResponseFormat = WebMessageFormat.Json,
           UriTemplate = "InsertPlan?PlanDate={Date}&Category={Category}&FoodName={food}&TCalories={calories}")]
       string InsertPlan(string Date, string Category, string food, string calories);
Posted
Updated 1-Aug-15 11:13am
v2
Comments
F-ES Sitecore 1-Aug-15 20:15pm    
Google "call asp.net web service jquery"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900