I have made a user control, and placed some code in the $(document).ready() method, but when I place breakpoints, by the boxWidth value, and step through, I can visibly see that the html has not yet loaded, and that is why I am getting undefined values. I need the html to load first, so that I can get the width and height of an img element to calculate aspect rations etc.
A screen shot is given below: