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

  • SEARCH
  • Home
  • 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 7647777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:32:52+00:00 2026-05-31T10:32:52+00:00

I have a Page with a Dynamic User Control in a placeholder. When I

  • 0

I have a Page with a Dynamic User Control in a placeholder.
When I load the Page it loads a UC ( let’s call it “OrigUC” ) by default. On this page I have a button , which replaced the UC with another “NewUC” . So this button postback using ajax and replaces the UC .

In the NewUC, In my Page_Load, I check for IsPostBack(), but for some reason, even though I loaded the UC for the first time it still returns me true. Why is it returning true, I thought the IsPostBack will return whether the UC since I’m checking it inside the Page_Load of the UC .Am I missing something?

Ok I now understand more the IsPostback on a user control coming from the Page it is called from… So how can I determine if it is the first time the UC is being called from the page?

Example:

If it is the first time the UC is called within the page, I need to querythe DB and also external WebS and bind the controls on the UC. If I trigger a partial postback , I do not want to query the DB and WebS again.

If (!IsUserControlPostBack) 
{ 
// Step 1 Init of UC 
// Call to DB 
// Call to WebS 
} 
else 
{ 
// A Post back occured ...  
// It can be Page who triggered it or UC and I do not want to call Step 1 again 
// DO something else. 
}

C

  • 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-31T10:32:53+00:00Added an answer on May 31, 2026 at 10:32 am

    Ok I’ve used ViewState to store the flag that I set when loading the User Control the first time I go in.

    Hope this help another noob like me 🙂

        private bool IsUCPostBack
        {
            get
            {
                object o = ViewState["S2UC"];
                return o == null;
            }
            set
            {
                ViewState["S2UC"] = true;
            }
        }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsUCPostBack)
            {
                IsUCPostBack = true; ... } else { ...   }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control...and the base page(s) which uses this user control has
I have a user control on a page and I'd like to load another
i have single php dynamic page that load image each time app user is
I have a web page that displays dynamic data which changes every 2 seconds.
I have a page that dynamically loads content based on a user pushing a
I have an ASP.NET user control that I want to write some dynamic Javascript
I have a user control which contains a CustomValidator which is used according to
I have a custom search control on my page (asp.net) which contains a textbox
I have a page in which I create dynamic controls via OnInit. On the
This is basically implementing search/find in a WPF window or User control. Let's say

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.