开发者

Sys.UI.DomElement.getBounds

开发者 https://www.devze.com 2023-02-14 15:43 出处:网络
I have an asp.net 4.0 web application I want to use Sys.UI.DomElement.getBounds to get panel\'s bounds. I have used following JQuery code:

I have an asp.net 4.0 web application I want to use Sys.UI.DomElement.getBounds to get panel's bounds. I have used following JQuery code:

var el = $get('#panel1');

var box = Sys.UI.DomElement.getBounds(el);

but I am getting error开发者_开发知识库 that Sys is not defined. Can you please tell me what are the pre requisites of using Sys.UI.DomElement.getBounds ?

Thanks,


Your mixing ASP.NET AJAX with JQuery, change your code to:

var el = $get('<%= panel1.ClientID %>');

var box = Sys.UI.DomElement.getBounds(el);

I'm assuming panel1 is a server control, otherwise, just do $get('panel1'); if not. You could also use JQuery's outerwidth and outerHeight or other methods found here: http://api.jquery.com/category/manipulation/ to get the size of an element.

HTH.


"Sys is undefined" will occur if the Microsoft Ajax JavaScript file(s) fail to load. Make sure this is not the case. To do so use Fiddler or Firebug and inspect your page for failing HTTP requests. Look for 404 and 500 HTTP codes.


I solved the problem. I used

var el = $get('#panel1');

var box = Sys.UI.DomElement.getBounds(el[0]);

and it worked.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号