asp.net - Page.Load runs every time and takes too long -


i have asp.net page this:

protected sub page_load(sender object, e system.eventargs) handles me.load     'page load code here.  call service layer, calls business layer. end sub  protected sub button1_click(sender object, e system.eventargs) handles button1.click     'button code here end sub 

the code in page_load takes long because has connect lots of different databases (code contained in business layer). best way cache page code in page_load not run before click event? code in page_load required generates controls. button1_click loops through these controls.

i tend focus on business layer , data layer. realize basic question.

page_load run before click event. need familiarize asp.net page lifecycle model , how postbacks work.

most of code runs in page_load shouldn't run again on postback, use if statement check if it's postback. loading of controls etc update viewstate , wont necessary reinitialize on postback.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -