Thursday, April 10, 2008

Get the position of web Controls using Javascript event though controls having no position declared

//-------Find top of Textbox --------------------------
var oNode = document.getElementById('TextBox1');
var iTop = 0;

while(oNode.tagName != "BODY") {
iTop += oNode.offsetTop;
oNode = oNode.offsetParent;
}

//Top of Textbox is now in iTop
document.write(iTop);
//--------------------------------------------------------


//--------Find Left of Textbox----------------------------
var iLeft = 0;
oNode = document.getElementById('UcEventType1_TextBox1');
while(oNode.tagName != "BODY") {
iLeft += oNode.offsetLeft;
oNode = oNode.offsetParent;
}

//Left position of textbox is displaying
document.write(iLeft);
//------------------------------------------------------------