Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to add movable textbox on my master page, which is movable means user can change its position or move it anywhere on form.

Please suggest me way which control i need to use and how it achieved.


Thanks in advance for your guidance.
Posted

You may use DIV with javascript. If you put the textbox inside the DIV then you can drag that. For dragging things see below

Movable DIV using JavaScript [^]

jQuery Draggable[^]
 
Share this answer
 
Comments
ambarishtv 20-Jun-11 6:20am    
my 5
You need to set the position of the textbox dynamic in which the user enter the values the X & Y.

use the MouseMove event and put the blow line

textBox1.Location = new Point(e.X, e.Y);
 
Share this answer
 
Try to use a textbox inside DragPanel[^]
 
Share this answer
 
By the following code using jquery you can insert a movable textbox in your page :




<title>jQuery scaffold






(function($) {
$.fn.drags = function(opt) {

opt = $.extend({handle:"",cursor:"move"}, opt);

if(opt.handle === "") {
var $el = this;
} else {
var $el = this.find(opt.handle);
}

return $el.css('cursor', opt.cursor).on("mousedown", function(e) {
if(opt.handle === "") {
var $drag = $(this).addClass('draggable');
} else {
var $drag = $(this).addClass('active-handle').parent().addClass('draggable');
}
var z_idx = $drag.css('z-index'),
drg_h = $drag.outerHeight(),
drg_w = $drag.outerWidth(),
pos_y = $drag.offset().top + drg_h - e.pageY,
pos_x = $drag.offset().left + drg_w - e.pageX;
$drag.css('z-index', 1000).parents().on("mousemove", function(e) {
$('.draggable').offset({
top:e.pageY + pos_y - drg_h,
left:e.pageX + pos_x - drg_w
}).on("mouseup", function() {
$(this).removeClass('draggable').css('z-index', z_idx);
});
});
e.preventDefault(); // disable selection
}).on("mouseup", function() {
if(opt.handle === "") {
$(this).removeClass('draggable');
} else {
$(this).removeClass('active-handle').parent().removeClass('draggable');
}
});

}
})(jQuery);

$(".draggable").drags();


 
Share this answer
 
Comments
Dave Kreskowiak 19-Dec-15 11:48am    
Don't drop an answer on a 4 year old question.

This question was already answered multiple times and your answer didn't add anything to the answers already posted.

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