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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:07:08+00:00 2026-05-24T21:07:08+00:00

This question continues from the two previous questions I have posted: 1) How to

  • 0

This question continues from the two previous questions I have posted:

1) How to get variables from .ascx in another .ascx?

2) C# asp.net textbox.text not setting?

My third question in relation is when I create a session and parse information through from ParentControl to ChildControl and then try to parse different information to a different instance of the ChildControl it copies the values from the second child control into the first child control.

Update: showing .ascx page which I missed out might be relevant.

ParentControl.ascx

<asp:PlaceHolder runat="server" id="ShowHideControls" Visible="false">    
    <asp:PlaceHolder runat="server" id="instanceOne" Visible="false">
        <uc1:ChildControl ID="controlOne" runat="server" />
    </asp:PlaceHolder>        
    <asp:PlaceHolder runat="server" id="instanceTwo" Visible="false">
        <uc1:ChildControl ID="controlTwo" runat="server" />
    </asp:PlaceHolder>
</asp:PlaceHolder>

ParentControl.ascx.cs

public void CreateSessionsAddressString(User user)
{
    if (user == user)
        Session["user"] = user;
}

instanceOne ChildControl.ascx.cs

public void SetUserDetails()
{   
    User user = Session["user"] as User;
    string fullAddress = User.fullAddress;
}

Now if I have a second instance of the same user control the following code is reused.

instanceTwo ChildControl.ascx

public void SetUserDetails()
{   
    User user = Session["user"] as User;
    string fullAddress = user.fullAddress;
}

On the instanceTwo when a set method is invoked to update information, instanceOne seems to populate itself with data from the instanceTwo. how can I prevent this from happening?


Update: Added further information to help solve issue below.

So in our solution we have a user who has an account, each account can have one additional user. I perform a check to see if user1 and user2 are not null.

If user1 is true and user2 is null then I don’t have an issue. It’s when user1 & user2 is true I get an issue with getting the information because when I call the method to get user information it seems to overwrite the user1 information in the user control.

I need to as some users have suggested wrap the code so it only affects itself and not other controls on the same page. I am going to go through some of the suggestions today and try get back to your comments asap.


Update I referred back to an earlier question I asked

1) How to get variables from .ascx in another .ascx?

I guess late Friday evening aren’t my best of times, I basically created a public method in the child control, and in the parent control I can call the public method for each instance so I can just type:

  instanceOne.MyMethod();
  instanceTwo.MyMethod();

This seems to be a good work around, and helps me avoid using sessions is well. I am going to request the question be removed because my solution is already in the a question before.

  • 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-24T21:07:10+00:00Added an answer on May 24, 2026 at 9:07 pm

    I think you’re running into this problem because you’re pulling the user object from session, and the user instance you’re creating still points to the object reference stored in session.

    Try something like this:

    string fullAddress = String.Copy(User.FullAddress);
    

    And you could try something like this too:

    private string fullAddress;
    public string FullAddress
    {
        get { return fullAddress; }
        set { fullAddress = String.Copy(value); }
    }
    
    public void SetUserDetails()    
    {           
        User user = Session["user"] as User;        
        this.FullAddress = user.fullAddress;   
    
        this.FullAddress = "Hello world!"; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first question here in stackoverflow. I have two processes, a root
I have my own control which derives from StackPanel. This control contains two other
And my confusion with JSF continues. This is a continuation of a question asked
This question is a follow up to my previous question about getting the HTML
This question is about removing sequences from an array, not duplicates in the strict
This question was very helpful, however I have a list control in my report,
This question has been answered. The problem was that myEventMoveTrainManaul() was being called from
I have two questions about using a BackgroundWorker: 1)Lets say you have Function A
This question is in continuation to my previous post located here . Since there
This is a question from recent GATE entrance exam. A process executes the code

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.