开发者

ASP.NET page life cycle and javascript events

I have the following setup -

ASP.NET page life cycle and javascript events

During the page_load(...) of each item, I register a jQuery window-onresize event to size each control depending on the size of its parent control.

The problem -- The window.resize events don't occur in the order I want them to because page_load() 开发者_如何学JAVAfor the aspx page occurs, then the master pages.

Using height="100%" in CSS is not possible because of padding and margins. Are there general strategies for dealing with this situation? I could use other page and control lifecycle events however, that seems a bit hacky.

I need suggestions; I've thought of assigning each control a precedence score and registering them with some global JS object and then run it in that order. Are there any better solutions?


Here's one idea (assuming you can use jQuery):

Register innermost child's onresize only. Then inside that onresize, call $(this).parent().trigger('onresize');

That will ensure it bubbles up the chain correctly.

Note: If you don't use jQuery, you can still implement this event bubbling in javascript.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜