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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:46:57+00:00 2026-05-22T18:46:57+00:00

I have a UserControl that allows the user to upload files and also displays

  • 0

I have a UserControl that allows the user to upload files and also displays them in a GridView. On the parent page, I have a jQuery tab control to which I dynamically add 2 instances of my UserControl (on different tabs). The second instance works fine, so I know the control works. However, when I try to upload a file using the first instance, the second instance is being referenced…so all property values, control names, etc are pointing that that of the second.

This is how I am loading the controls in the parent page code-behind:

protected void Page_Load(object sender, EventArgs e)
{
  MyControl ucAttachments1 = (MyControl) Page.LoadControl("~/controls/mycontrol.ascx");
  ucAttachments1.ID = "ucAttachments1";
  ucAttachments1.Directory = "/uploads/documents";
  ucAttachments1.DataChanged += new MyControl.DataChangedEventHandler(DoSomething);
  phAttachments1.Controls.Add(ucAttachments1);

  MyControl ucAttachments2 = (MyControl)Page.LoadControl("~/controls/mycontrol.ascx");
  ucAttachments2.ID = "ucAttachments2";
  ucAttachments2.Directory = "/uploads/drawings";
  ucAttachments2.DataChanged += new MyControl.DataChangedEventHandler(DoSomething);
  phAttachmetns2.Controls.Add(ucAttachments2);
}

in the html:

<div id="tabContainer">
    <div id="files">
        <asp:PlaceHolder id="phAttachments1" runat="server" />
    </div>
    <div id="drawings">
        <asp:PlaceHolder id="phAttachments2" runat="server" />
    </div>
</div>

a snippet of the user control code:

private string directory;

override protected void OnLoad(EventArgs e)
{
    PopulateAttachmentGridview();
}

protected btnUpload_Click(object sender, EventArgs e)
{
    UploadFile(directory);
}

public string Directory
{
    get { return directory; }
    set { directory = value; }
}

How can I ensure my usercontrols are being referenced correctly?

  • 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-22T18:46:58+00:00Added an answer on May 22, 2026 at 6:46 pm

    Check the actual html and javascript rendered to the client to ensure that there isn’t a duplicate ID related to the controls slipping through the cracks.

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

Sidebar

Related Questions

I have a made a simple UserControl that allows a user to drag a
I have a simple UserControl that I've created that simply allows a user to
I have a user control that allows items to be added to it by
I have a User Control displaying some data and a button that displays a
I have a ASP.NET GridView that uses template columns and user controls to allow
I have made a user control that allows an image to be uploaded and
I have an UserControl that contains a Button : <UserControl> <Button> </UserControl> I want
I have a UserControl that has a BaseClass object as a public member. Right
I have a UserControl that I want to add at runtime to my current
I have a usercontrol that hides a div when a button is clicked. <asp:LinkButton

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.