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);
//------------------------------------------------------------

1 comment:

Anonymous said...

Hello. This post is likeable, and your blog is very interesting, congratulations :-). I will add in my blogroll =). If possible gives a last there on my blog, it is about the Livros e Revistas, I hope you enjoy. The address is http://livros-e-revistas.blogspot.com. A hug.