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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:07:37+00:00 2026-05-27T13:07:37+00:00

i have a aspx page in which i have placeholder inside the panel as

  • 0

i have a aspx page in which i have placeholder inside the panel

as

<div>
    <div>
        <div>
            <div>
                <div>
                    <div>
                        <asp:UpdatePanel runat="server" ID="UpdatePanelLinks">
                            <ContentTemplate>
                                <center>
                                    <asp:Button Text="ADD" ID="btnAdd" runat="server" Width="100" OnClick="btnAdd_Click" />&nbsp;
                                    <asp:Button Text="Edit" ID="btnEdit" runat="server" Width="100" OnClick="btnEdit_Click" />&nbsp;
                                    <asp:Button Text="Delete" ID="btnDelete" runat="server" Width="100" OnClick="btnDelete_Click" /></center>
                                <asp:LinkButton ID="usercontroldata" runat="server" Text="Branches" 
                                    OnClick="usercontrol_Click"></asp:LinkButton>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>
                </div>
                <div >
                    <asp:LinkButton ID="lnkDepartments" runat="server" Text="Departments" OnClick="lnkDepartments_Click"></asp:LinkButton>
                </div>
                <div >
                </div>
                <div >
                    <asp:LinkButton ID="lnkProjects" runat="server" Text="Projects" OnClick="lnkProjects_Click"></asp:LinkButton>
                </div>
                <div >
                </div>
                <div >
                    &nbsp;
                </div>                       
            </div>
            <div>
                <div>
                    <asp:Label Text="" Visible="false" ID="lblmessage" runat="server" />
                    <div>
                        <asp:UpdatePanel ID="UpdatePanel" runat="server">
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="lnkBranches" EventName="Click" />
                                <asp:AsyncPostBackTrigger ControlID="lnkDepartments" />
                                <asp:AsyncPostBackTrigger ControlID="lnkProjects" />
                                <asp:AsyncPostBackTrigger ControlID="btnAdd" />
                                <asp:AsyncPostBackTrigger ControlID="btnEdit" />
                                <asp:AsyncPostBackTrigger ControlID="btnDelete" />
                            </Triggers>
                            <ContentTemplate>
                                <asp:Panel runat="server" ID="MainPanel">
                                    <div class="padding_branch">
                                        <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
                                    </div>
                                </asp:Panel>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<asp:UpdatePanel ID="UpdatePanel" runat="server">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="lnkBranches" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="lnkDepartments" />
        <asp:AsyncPostBackTrigger ControlID="lnkProjects" />
        <asp:AsyncPostBackTrigger ControlID="btnAdd" />
        <asp:AsyncPostBackTrigger ControlID="btnEdit" />
        <asp:AsyncPostBackTrigger ControlID="btnDelete" />
    </Triggers>
    <ContentTemplate>
        <asp:Panel runat="server" ID="MainPanel">
            <div >
                <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>                                     
            </div>
        </asp:Panel>
    </ContentTemplate>
</asp:UpdatePanel>    

and on the aspx.cs page i am dynamically add the web user control on click of links

and on the add button click the new user control is loaded

 protected void usercontrol_Click(object sender, EventArgs e)
 {
        if (ViewState["controlname"] != null)
        {
            PlaceHolder pl = MainPanel.FindControl(ViewState["controlname"].ToString()) as PlaceHolder;
            if (pl.Controls.Count > 0)
            {
                pl.Controls.RemoveAt(0);
            }
        }

        Control uc = (Control)Page.LoadControl("~/usercontrol_Data.ascx");

        ViewState["path"] = "~/usercontrol_Data.ascx";
        ViewState["controlname"] = "PlaceHolder1";
        ViewState["name"] = "usercontrol";
        PlaceHolder1.Controls.Add(uc);
 }

i am also mainaining the web user control on Page_Load

        if (Page.IsPostBack)
        {
            if (ViewState["path"] != null)
            {
                Control uc1 = (Control)Page.LoadControl(ViewState["path"].ToString());

                PlaceHolder pl = MainPanel.FindControl(ViewState["controlname"].ToString()) as PlaceHolder;
                pl.Controls.Add(uc1);
            }
        }

and there is dropdown list on the form user control when iam selecting any of the option from the user control it post back and all the other fields become empty for textboxes etc . this happans for the first time and for next time all the fields retain there values

please help

thanks

  • 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-27T13:07:38+00:00Added an answer on May 27, 2026 at 1:07 pm

    i have done this by assigning the same ID to the control every time when the control loads dynamically. this is because when the control added dynamically every time it get the new ID that is creating the problem for me

    uc1.ID=”Web_User_Control_ID”;

    every time the control load asign this ID to it will resole the problem

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a panel on an aspx page which contains an UpdatePanel. This panel
I have a masterpage with an update panel: <asp:UpdatePanel ID=UpdatePanel runat=server ChildrenAsTriggers=true EnableViewState=False UpdateMode=Conditional>
I have an ASPX page (On server A) which is invoked using NTLM credentials.
I have one aspx page with some controls. Also i have one DIV which
I have a < div > in my aspx page which has some notification
I have an aspx page which has a GridView and a Panel with Summary
I have a aspx page and inside I have called a .ascx page which
I've a ASP.Net page (Default.aspx) which will load UserControl (ucontrol.ascx) dynamically into an UpdatePanel.
I have an aspx page in which i have 3 asp.net text boxes and
I have the .aspx page which is already developed in VS 2008 with its

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.