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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:04:46+00:00 2026-05-31T02:04:46+00:00

I have a user control on the master page and I would like to

  • 0

I have a user control on the master page and I would like to pass in a value into that user control from the subpage, how would I be able to pass the values?

This control is in the master page

<%@ Register TagPrefix="test" TagName="Data" Src="controls/TEST.ascx" %>

This code variable is within the user control

public partial class Controls_TEST : System.Web.UI.UserControl
{
    private string _Title;
    public string Title
    {
        get { return _Title; }
        set { _Title = value; }
    }
}

Code within the subpage

public partial class sub_page : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
         Controls_Test m = LoadControl("~/Controls/TEST.ascx");
         m.Title = "TEST";
    }
}

Note the sample code within subpage does not work because it cannot find that user control within the subpage.

I’ve tried Page.Master.FindControl and it also does not work for me. PLease help.

  • 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-31T02:04:47+00:00Added an answer on May 31, 2026 at 2:04 am

    Use properties to communicate from your Page to your MasterPage and use properties to communicate from your MasterPage to the UserControl.

    To get a reference to the control in your MasterPage you should provide a public property that returns it:

    For example(in MasterPage):

    public Controls_Test MyControl
    {
         get
         {
             return Controls_TEST1;
         }
    }
    

    And you can call this property from one of your ContentPages in this way(f.e. if your master’s type is named “SiteMaster“):

    protected void Page_Load(object sender, EventArgs e)
    {
        ((SiteMaster)Page.Master).MyControl.Title = "TEST";
    }
    

    As a rule of thumb: the more you encapsulate your controls, the more robust ,failsafe, maintanable and extendable your code will be.

    Hence it would be better to provide only access to the Title rather than to the whole UserControl.

    In MasterPage:

    public String Title
    {
         get
         {
             return Controls_TEST1.Title;
         }
        set
        {
            Controls_TEST1.Title = value;
        }
    }
    

    In the ContentPage:

    ((SiteMaster)Page.Master).Title = "TEST";
    

    On this way you could change the logic and controls in your UserControl and MasterPage without having problems in your pages that already have accessed the UserControl directly.

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

Sidebar

Related Questions

Lets say that I have a header user control in a master page, and
I would like to add a control to a master page (that will go
I have a user control in a master page and the same user control
I have a user control in a master page with two drop down lists.
I have a user control in a repeater that I need to pass data
I have a master page that gets all its images from a table on
I have a User Control that have a global resource with a string value
I have a user control that is pretty basic. It contains several TextBox controls,
I have a user control that is emmitting javascript using the ClientId function. For
I have a master page which has some user controls within an update panel.

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.