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 7498463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:29:11+00:00 2026-05-29T19:29:11+00:00

This is really important question. this makes me crazy in 4 hours :( i

  • 0

This is really important question. this makes me crazy in 4 hours 🙁 i can load UCAddX.ascx but if i click “Search in X” button not load UCSearchX user control. There are 3 button also there are 3 web user control. i want to load these 3 web user controls after clickEvents. But below method not working.How to load web user control dynamically? Click By Click (Like Tab control)

 public partial class MyPage: System.Web.UI.Page
    {
   protected void Page_Load(object sender, EventArgs e)
        {
            ViewState["controlType"] = "AddX";
            if (!IsPostBack)
            {
                AddUserControl();
            }
            else
            {
                AddUserControl();
            }
        }

        protected void btnAddX_Click(object sender, DirectEventArgs e)
        {
            ViewState["controlType"] = "AddX";
            if (!IsPostBack)
                  AddUserControl();
            else
                AddUserControl();
        }

        protected void btnSearchX_Click(object sender, DirectEventArgs e)
        {
            ViewState["controlType"] = "SearchX";
            if (!IsPostBack)
                AddUserControl();
            else
                AddUserControl();

        }
        protected void btnUpdateX_Click(object sender, DirectEventArgs e)
        {

        }

        void AddUserControl()
        {
          //  plhContent1.Controls.Clear();
            if (ViewState["controlType"] != null)
            {
                if (ViewState["controlType"].ToString() == "AddX")
                {
                    UCAddX uc = (UCAddX)Page.LoadControl("~/Pages/EN/MyUserControls/UCAddX.ascx");
                    uc.ID = "ucAddX";
                    uc.Attributes.Add("runat", "Server");
                    uc.EnableViewState = true;
                    uc.Visible = true;
                    plhContent1.Controls.Add(uc);
                }
                else if (ViewState["controlType"].ToString() == "SearchX")
                {
                    UCSearchX uc = (UCSearchX)Page.LoadControl("~/Pages/EN/MyUserControls/UCSearchX.ascx");
                    uc.ID = "ucSearchX";
                    uc.Attributes.Add("runat", "Server");
                    uc.EnableViewState = true;
                    uc.Visible = true;
                    plhContent1.Controls.Add(uc);
                }


            }
        }

    }
  • 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-29T19:29:12+00:00Added an answer on May 29, 2026 at 7:29 pm

    try something like this,

    //to load the control
         protected void Page_Init(object sender, EventArgs e)
         {
             ViewState["controlType"] = "AddSector";
             //you don't need to check the if condiontion, cause you load every time the controls
             AddUserControl();
          }
    

    when you need to get values from the control after postback you should get it on

    protected void Page_PreRender(object sender, EventsArgs args) {
        //your placeholder that contains data
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question is not really important.. however I've been wondering: Which of
Important: This question isn't actually really an ASP.NET question. Anyone who knows anything about
This really seems like a bug to me, but perhaps some databinding gurus can
This really puzzled for hours, I searched all over the internet, but got no
This really, really urks me, so I hope that someone can give me a
This really has my stumped today. I'm sure its simple, but... Here is my
This really shouldn't be hard, I just can't figure out how to do it.
My question is really very important . When i program i have seen that
I apologize for a lengthy question, but I really need your help. As a
First let me say that I really feel directionless on this question. I am

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.