Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6553527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:35:33+00:00 2026-05-25T12:35:33+00:00

I am thinking to stop the execution of pageload if that UC has been

  • 0

I am thinking to stop the execution of pageload if that UC has been set to Visible false at the container page. Right now I am upto the following logic

public class TestControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.Visible)
        {
            //do heavy operation

        }
    }
}

i.e I will check whether the control is visible false or not in the Page load of UC, if true, then only do the operations there. Is there any other better way to do so? I have so many UC in my application. Is there some common logic to stop the execution of page load of UC if it is Visible false.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:35:33+00:00Added an answer on May 25, 2026 at 12:35 pm

    The Visible property of the Control class only determines if the Control is rendered, it has no effect on the rest of a control’s life cycle though.

    From MSDN:

    If this property is false, the server control is not rendered. You should take this into account when organizing the layout of your page. If a container control is not rendered, any controls that it contains will not be rendered even if you set the Visible property of an individual control to true. […]

    This makes sense, because that way you can have invisible controls that still perform a certain action. You could also do this by just not putting any content into them, but they probably still will render some whitespace or newline. Setting Visible to false is the clean way to do it.

    I don’t think there is any better way to prevent the execution of code if the Control is not visible, but I think you’re solution is clean enough.

    As an alternative you could put your code into the OnPreRender event, which is only fired when the control is visible. But keep in mind that this is a later step in the Control Lifecycle.

    public class TestControl : System.Web.UI.UserControl
    {
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            // Your code here
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Been thinking about this for hours now. Im building a simple slideshow application, where
Thinking it has something to do with my container div and their CSS. But
I've been thinking for hours about this problem now without finding a solution. Still
I think I am right in thinking that if I have a program like
Thinking about avoiding code replication, I got a question that catches me every time
Thinking that the answer to this is pretty obvious but here it goes: When
Just thinking about the best way to build an Order form that would (from
How do I stop thinking every query in terms of cursors, procedures and functions
I need to stop publishing of a page when a certain condition exists, for
I have a problem that I have been trying to figure out for hours

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.