Click here to Skip to main content
15,915,600 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Nightly, weekly, monthly autoevents? Pin
DigiOz Multimedia17-Sep-07 4:52
DigiOz Multimedia17-Sep-07 4:52 
Questiona gridview problem [xmldatasource & xml/xapth][2] Pin
pidakar16-Sep-07 5:53
pidakar16-Sep-07 5:53 
Questiona gridview problem [xmldatasource & xml/xapth] Pin
pidakar16-Sep-07 5:41
pidakar16-Sep-07 5:41 
AnswerRe: a gridview problem [xmldatasource & xml/xapth] Pin
Sandeep Akhare16-Sep-07 20:31
Sandeep Akhare16-Sep-07 20:31 
Questiondatabinding with controls Pin
prachishah16-Sep-07 1:02
prachishah16-Sep-07 1:02 
Questionpost data from asp.net 2.0 page to PHP Page Pin
Ahmad Adnan15-Sep-07 23:09
Ahmad Adnan15-Sep-07 23:09 
AnswerRe: post data from asp.net 2.0 page to PHP Page Pin
Guffa16-Sep-07 2:04
Guffa16-Sep-07 2:04 
QuestionJavascript drag and drop problem Pin
Dot Net15-Sep-07 19:02
Dot Net15-Sep-07 19:02 
Hi All,
I am trying to drag and drop a div in javascript. I am calling this function on button click event.

function CreateControl(id) {
var ctrlString="
";
ctrlString+="
";
ctrlString+="
";
ctrlString+="";
ctrlString+="";
ctrlString+="
";
return ctrlString;
}

This function creates a div which contains two other divs and one textbox and a button. Actually it is a chat box window which has a header, message area and textbox in which user types in message and click on send button to post to it other user.

I am using following code to drag and drop this control:

document.onmousemove = mouseMove;
document.onmouseup = mouseUp;

var dragObject = null;
var mouseOffset = null;

function mouseCoords(ev){
if(ev.pageX || ev.pageY){
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}

function mouseUp(){
dragObject = null;
}

function ClearAllObjects() {
dragObject=null;
}

function getMouseOffset(target, ev){
ev = ev || window.event;
var docPos = getPosition(target);
var mousePos = mouseCoords(ev);
return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
}

function getPosition(e){
var left = 0;
var top = 0;

while (e.offsetParent){
left += e.offsetLeft;
top += e.offsetTop;
e = e.offsetParent;
}

left += e.offsetLeft;
top += e.offsetTop;

return {x:left, y:top};
}

function mouseMove(ev){
ev = ev || window.event;
var mousePos = mouseCoords(ev);
if(dragObject){
document.getElementById("Text2").value=dragObject.id;
dragObject.style.position = 'absolute';
dragObject.style.top = mousePos.y - mouseOffset.y;
dragObject.style.left = mousePos.x - mouseOffset.x;
return false;
}
}
function mouseUp(){
dragObject = null;
document.getElementById("Text2").value="0";
}

function makeDraggable(item){
var obj=document.getElementById(item).parentElement;
document.getElementById("Text1").value=item;
if(document.getElementById("Text2").value="1") {
if(!obj) return;
obj.onmousedown = function(ev){
dragObject = this;
mouseOffset = getMouseOffset(this, ev);
return false;
}
}
else {
dragObject=null;
}
}

function Button1_onclick() {
var txtId=document.getElementById("Text1").value;
if(txtId!=null){
document.getElementById("Text1").value=document.getElementById ("Text1").value + 1;
var divHtml=CreateControl(document.getElementById("Text1").value);
}
else {
document.getElementById("Text1").value=1;
}
document.getElementById("mainSpace").innerHTML=document.getElementById("mainSpace").innerHTML + divHtml;
}

Now the problem is that i want that window should be dragged by clicking on header only. It works fine when page is loaded first time. But once i drag it from header then after that it gets dragged on mousedown event on any area of the window. I have tried to figure out the problem but to no vain. I will appreciate if somebody knows the solution of this problem.


Thanks,
Ahmad

QuestionHow to use asp:ImageField in a GridView Pin
RoyRose7815-Sep-07 7:12
RoyRose7815-Sep-07 7:12 
Questionbreaking out into server code while rendering javascript Pin
Guy Harwood15-Sep-07 5:50
Guy Harwood15-Sep-07 5:50 
AnswerRe: breaking out into server code while rendering javascript Pin
MoustafaS15-Sep-07 10:15
MoustafaS15-Sep-07 10:15 
AnswerRe: breaking out into server code while rendering javascript Pin
MoustafaS15-Sep-07 10:15
MoustafaS15-Sep-07 10:15 
GeneralRe: breaking out into server code while rendering javascript Pin
Guy Harwood16-Sep-07 3:33
Guy Harwood16-Sep-07 3:33 
QuestionSelecting a role when registering a user Pin
DarynRoberts15-Sep-07 3:18
DarynRoberts15-Sep-07 3:18 
QuestionAssembly in asp.net Pin
Rinki Mukheraji15-Sep-07 1:54
Rinki Mukheraji15-Sep-07 1:54 
AnswerRe: Assembly in asp.net Pin
ademsandeepreddy15-Sep-07 20:12
ademsandeepreddy15-Sep-07 20:12 
AnswerRe: Assembly in asp.net Pin
Paras Kaneriya16-Sep-07 19:29
Paras Kaneriya16-Sep-07 19:29 
Question[Urgent] Can someone tell me how to put an Html file into a pdf? Pin
Big Ralph14-Sep-07 23:26
Big Ralph14-Sep-07 23:26 
Questiondisplay image in GridView using image URL string "C:\images\abc.jpg" Pin
mavii14-Sep-07 23:21
mavii14-Sep-07 23:21 
AnswerRe: display image in GridView using image URL string "C:\images\abc.jpg" Pin
Saksida Bojan15-Sep-07 7:23
Saksida Bojan15-Sep-07 7:23 
AnswerRe: display image in GridView using image URL string "C:\images\abc.jpg" Pin
Paras Kaneriya16-Sep-07 19:31
Paras Kaneriya16-Sep-07 19:31 
Questioncan any one tell me how to use the Trim() function in C# for any column in a table Pin
mavii14-Sep-07 23:00
mavii14-Sep-07 23:00 
AnswerRe: can any one tell me how to use the Trim() function in C# for any column in a table Pin
Sonia Gupta14-Sep-07 23:02
Sonia Gupta14-Sep-07 23:02 
GeneralRe: can any one tell me how to use the Trim() function in C# for any column in a table Pin
mavii14-Sep-07 23:10
mavii14-Sep-07 23:10 
AnswerRe: can any one tell me how to use the Trim() function in C# for any column in a table Pin
Guffa15-Sep-07 0:37
Guffa15-Sep-07 0:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.