Is the following statement about PreRender true?
Would a call to a database be called if you put the databind method in the PreRender event o开发者_开发问答f a listbox and the listbox was rendered on the screen for example? This is a specific example regarding a listbox, but basically does code in PreRender only get called if the control is rendered on the screen. If this is so, is it good practice to put code into PreRender such as databinding?
edit: you just changed your question, I think the answer is still yes... but the following still applies:
The PreRender
event of the listbox
will only fire if the control is set to Visible=true
on the page.
So if you do your DataBind
(and associated database calls) in the PreRender
it will not call your database if it is set to Visible=False
.
You can test this quite easily by sticking a break point in the PreRender
and changing the visibility of the control in the HTML.
精彩评论