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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:15:27+00:00 2026-05-13T14:15:27+00:00

I have a User Control with a label on it. I have a Master

  • 0

I have a User Control with a label on it. I have a Master Page that I have dropped the User Control on. I have other .aspx pages that use the master page that has the user control on it.

What is the best way to change the text of that label on the user control from the .aspx page?

  • 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-13T14:15:28+00:00Added an answer on May 13, 2026 at 2:15 pm

    You have a couple of options but the best way would be to create a method on the user control that wraps the text property of your label and allows users to pass in a value that you in turn assign to the label’s Text property.

    Then create another method on your Master Page that accepts a string parameter and passes that value through to the method on your user control. Then you can call this method on your Master Page from your web form.

    So on your user control add a method like this:

    Public Sub SetDisplayText(ByVal displayText As String)
        SomeLabel.Text = displayText
    End Sub
    

    then add a method to your Master Page like this:

    Public Sub SetDisplayText(ByVal displayText As String)
        SomeUserControl.SetDisplayText(displayText)
    End Sub
    

    Now your web form can call the SetDisplayText method on the Master Page to set the text on the user control’s label:

    Dim masterPage As SomeMasterPage = TryCast(Me.Master, SomeMasterPage)
    
    If masterPage IsNot Nothing Then
        masterPage.SetDisplayText("foo")
    End If
    

    This may feel like overkill but this kind of abstraction is necessary to reduce coupling between your components. This approach also gives you a lot of flexibility moving forward as changes can be made without affecting other components. For instance, if you rename your label control you will not need to go change the web form that sets its text value as the web form won’t know (or care) what the label is called, only how to set its display value.

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

Sidebar

Related Questions

I have a user control called GameButton that has a label inside it. When
I have a user control that contains multiple controls (CheckBox, Button, Label...). I want
I have created a user control (link) which has a label and a button.
I have a user control that is being integrated to the page on run
I have created user control for menu bar and loading in Master page. User
For example, I have a user control(ascx) with a label inside, I will use
I have placed my user control (my.ascx) on the web page (1.aspx). my.ascx contains
I have a dropdownlist in aspx page. I have a gridview in user control.I
I have created a user control that has an asp:login control in it. I
I have an User Control that host another controls like panel, chart controls. Right

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.