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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:21:19+00:00 2026-05-25T13:21:19+00:00

I have two user controls inside an ASPX page. All I want to do

  • 0

I have two user controls inside an ASPX page. All I want to do is pass one single int from one control to the other during page load.

I have tried several of the examples on here but none of them work – sorry I mean I can’t get them to work! Here’s what I’ve got:

Default.ASPX

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ucBottom.varBottomID = ucTop.varBottomID;     
    }
}

UCTOP

public partial class ucTop : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int varBottomID = 100;
    }
}

UCBOTTOM

public partial class ucBottom : System.Web.UI.UserControl
{
    public int varBottomID { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        BottomText.Text = Convert.ToUInt32(varBottomID).ToString();
    }
}

There are no errors except for BottomText.Text returning 0 instead of 100. Also int varBottomID = 100; is stating that it is assigned but never used (ucTop).

From one of the answers here it’s good practice for one UC not to be aware of the other and to use the parent to pass data. But alas not for me.

As always, any help would be appreciated (but in a below dummies guide format!).

EDIT – Sorry A typo crept in the code in Default…

  • 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-25T13:21:20+00:00Added an answer on May 25, 2026 at 1:21 pm

    In your main page, it’s not really changing anything — it’s setting ucBottom.varBottomID to itself. (Edit: appears to have been fixed)

    In ucTop, int varBottomID = 100; does nothing — it sets a variable inside the function, which won’t be visible outside.

    The result of those two issues is that you never end up having anything communicated from ucTop to ucBottom.

    (BTW, convention is to start class names with an uppercase letter, and instance names with a lowercase letter. It’s not exactly obvious from looking at the code whether you’re attempting to access static or instance members of your classes. From here on i’m assuming you have a ucBottom control, which is an instance of the ucBottom class, and the same for ucTop. It’s the only case i see where your code, as pasted, would compile without errors.)

    You may need something similar to:

    public partial class _Default : Page
    {
        protected void Page_Load(sender obj, EventArgs e)
        {
            ucBottom.varBottomID = ucTop.varBottomID; // fix the first issue
        }
    }
    
    public partial class ucTop : UserControl
    {
         public int varBottomID { get; set; } // fix the second issue
         protected void Page_Load(object src, EventArgs e)
         {
             varBottomID = 100;
         }
    }
    

    You will also need to pick different events to trigger on, if you go this route. If everything triggers on Load, you have a problem — Load fires on the page first, then on the child controls. So the property won’t get set correctly. (The setting goes in 3 steps: ucTop deciding the correct value to set, _Default setting it from top to bottom, and ucBottom using it. You need that sequence to go decide, set, use in order for it to work correctly, but if everything triggers on Load you’ll end up with set, decide, use or set, use, decide.) You might consider letting _Default do its thing on LoadComplete, and ucBottom on PreRender.

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

Sidebar

Related Questions

I have user control named DateTimeUC which has two textboxes on its markup: <asp:TextBox
I have a tab container in aspx page and i want to enable disable
I'm trying to perform two-way data binding on the controls in my user control,
I have a custom user control DatePicker.cs. Inside of another piece of code I
I'm using LINQ to SQL and C#. I have two LINQ classes: User and
I have two models indexed for searching (User and Item). I'm trying to do
Suppose you have two models, User and City, joined by a third model CityPermission:
I have a simple database with two tables. Users and Configurations. A user has
I have an ascx component, that holds two-level menu, because there are several user
I have two arrays of System.Data.DataRow objects which I want to compare. The rows

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.