<script type="text/javascript">
$(function() {
$('#WaterMark').draggable(
{
start: function(e, ui) {
},
cursor: 'move',
zIndex: 2700,
revert: 'invalid',
containment: '#OriginalImageContainer'
});
$('#OriginalImage').droppable({
hoverClass: 'DroppableOver',
drop: InitializeWaterMark
})
});
var InitializeWaterMark = function() {
var position = $('#WaterMark').position();
var imgPosition = $('#OriginalImageContainer').position();
document.getElementById('xpos').value = position.left - imgPosition.left;
document.getElementById('ypos').value = position.top - imgPosition.top;
}
</script>
this is a sample javascript code i got regarding drag and drop of images in a asp.net webpage...But it returns a error stating '$' is undefined..please help me out
At a guess, I'd say you were missing the library to support that script (probably jQuery).
You need to include a reference to the JavaScript framework in order to get the draggable functionality you're looking for.
Try adding the following to your page (before the script block in your example):
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.7.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/jquery-ui.js"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With