Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Do not execute invisible usercontrol

  Asked By: Jamil    Date: Sep 18    Category: Asp.net    Views: 1040
  

How can I prevent the code inside an invisible user control's (Visible=false) Page_Load from firing until it gets visible?

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Rosa Reynolds     Answered On: Sep 18

I'm not sure if I totally understand your question - but if a control's visible  state is set to false, it isn't rendered, and the code  contained in it shouldn't fire (no practical experience with this - just remembering something I read). If I'm wrong with this, would placing the user  control in a panel and setting the panel to visible=false work?

 
Answer #2    Answered By: Geldefsman Bakker     Answered On: Sep 18

Get that code  out of Page_Load

Have it live in a sub or method.

Have the visible  property set invoke the method or the page.

Look at:
www.learnasp.com/.../sourcecode-searcheruc.aspx

specifically:
dbgrid.ascx

The database population code could not live in Page_Load because it would fire before the button event that gave it correct SQL. So that code lives in a sub called DataBind() although it could have been called GoGetdata() or whatever...

 
Answer #3    Answered By: Von Fischer     Answered On: Sep 18

This will enhance performance greatly on my page + prevent  errors because variables could be null when the control is invisible  (not yet in scope).

 
Didn't find what you were looking for? Find more on Do not execute invisible usercontrol Or get search suggestion and latest updates.




Tagged: