Jquey drag and Drop controls draggable usage (asp.net environment) _jquery

Source: Internet
Author: User
The main purpose of this example is to use the Jquey draggable control.

Use first in turn refers to Jquery,jquery-ui, draggable three JS. Then write the corresponding code in JS, the relevant code description please see the comments in the program.

For instructions on Draggable please refer to: http://docs.jquery.com/UI/API/1.8/Draggable

Source:
Copy Code code as follows:

<%@ Page language= "C #" autoeventwireup= "true" codebehind= "Default.aspx.cs" inherits= "Jquerydrag._default"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title></title>
<script type= "Text/javascript" src= "Js/jquery-1.4.2.min.js" ></script>
<script type= "Text/javascript" src= "Js/jquery-ui-1.8.custom.min.js" ></script>
<script type= "Text/javascript" src= "Js/draggable.js" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
Drag and Drop method
$ ("#imgDrag"). Draggable ({
Drag range
Containment: "#DragArea",
Start Event
Start:function (event, UI) {
StartDrag (event, UI);
},
End Event
Stop:function (event, UI) {
EndDrag (event, UI);
}
})
});
Start Event method
function StartDrag (event, UI) {
$ ("#StartDragInfo"). HTML ("Start: Left:" + Ui.offset.left + "on:" + ui.offset.top);
}
End Event Method
function EndDrag (event, UI) {
$ ("#EndDragInfo"). HTML ("End: Left:" + Ui.offset.left + "on:" + ui.offset.top);
}
</script>
<body>
<form id= "Form1" runat= "Server" >
<%--draggable Reference Manual Http://docs.jquery.com/ui/api/1.8/draggable--%>
<%--Drag Range--%>
<div id= "Dragarea" style= "width:500px; height:500px; BORDER:1PX solid Blue ">
<%--records the information at the start of a drag--%>
<div id= "Startdraginfo" >
</div>
<%--records the information at the end of the drag--%>
<div id= "Enddraginfo" >
</div>
<br/>
<br/>
<%--the object being dragged--%>

</div>
</form>
</body>

File package Download
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.