jqueryasp.netmaster-pagesjquery-eventsascx

ASP.NET page life cycle and javascript events


I have the following setup -

enter image description here

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() for 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?


Solution

  • 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.