Ads 468x60px

Thursday, April 26, 2012 Loading Algorithm! HECK

Usually websites do not release their loading algorithms but i am different , i am more like a one-man-army :P ... well 4 days back the loading of was little like you had to wait for 10 seconds for each page to show up , While coding the pages i felt bored waiting,wanting to see the output of what i had coded .. so i decided upon a loading algorithm which is far better than that of facebook

So , i went about having multiple approaches which led to multiple problems, one of the most ass-holed method of doing this is by using iframes... they may give that (enabling of browser's) 'Back' button advantage but at the end of the day , they do not provide security , they load the pages instead of controls ...

Second method was to load user-controls dynamically using update panels .. each time u clicked the button ,  a user-control would load up , this had its own set of problems and approaches as well because the controls (if u wanted them to behave like normal user-controls) then u had load them in Page_Init event ... if u do that in any other event then the controls in the user-controls will not fire their own events, yes u r right we can solve this problem by using viewstates and trying to figure out in which page life cycle which event fires.. but this method although possible was rejected because using this method meant that we are loading user-controls again which are already loaded ... what i mean the user-controls had to be , had to be  kept in one page..

So I came up with 3rd and most efficient method (this method is also used by Google + and new Gmail) this approach keeps the user-controls loaded in the same page but sets their display as none , u can use hidden input to pass required parameters to button , user-controls and the panels u r using .So when u click at at the link , it checks weather the user-control is already loaded or not(via javascript) if it is then it sets its postback to false and displays that following user-control and if it is not then the event is passed to server-side and then the user-control is loaded in the page ... but it created one more problem if their is postback in the user-control , the parameters gets refreshed and their is no postback at all (weird , i know but it happened!!) so the only way is to ajaxify all the usercontrols using couple of more update panels and javascript snippets . Yeah Tough ... but it was worth it ... time saved is always worth it .. isn't it guys..
Will Keep Posting

No comments:

Post a Comment