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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:44:48+00:00 2026-05-15T10:44:48+00:00

How can I pass user control properties to the page AND make these properties

  • 0

How can I pass user control properties to the page AND make these properties available to all methods on the page (and not just to one method that is fired on a control action, e.g. onControlClick)

I have a set up of essentially 3 pages:

  • user control (ascx/cs)
  • class (cs) – that contains user control properties
  • host page (aspx/cs) – references the user control

The user control consists of 3 interrelated dropdowns. I’m having success passing these dropdown values through a class onto the page via an event that is fired when a user clicks on the dropdown menu. So this way the host page is continously aware of the values in the user control. However, I want the page to use the control’s properties (stored in a class) on all of its methods – how do I make this user control class available to all?

Also I’m using ASP.NET and C# by the way.

Here’s the Code (not sharing the full code here – just the snippets of a similar code block)

On the ASPX for Menu Host Page:

<linked:LinkMenu2 id="Menu1" runat="server" OnLinkClicked="LinkClicked" />

Host Page (cs):

protected void dropdownclicked(object sender, ddtestEventArgs e)
{
    if (e.Url == "Menu2Host.aspx?product=Furniture")
    {
        lblClick.Text = "This link is not allowed.";
        e.Cancel = true;
    }
    else
    {
        // Allow the redirect, and don't make any changes to the URL.
    }
}

Host Page (aspx)

<asp:dropdowncustom ID="dddone" runat="server" OnddAppClicked="dropdownclicked" />

Control (cs)

public partial class usercontrol_tests_dropdown1 : System.Web.UI.UserControl
{
    public event ddtestEventHandler ddAppClicked;
}

    public void selectapp_SelectedIndexChanged(object sender, EventArgs e)
    {
        ddtestEventArgs args = new ddtestEventArgs(selectlink.SelectedValue);
        ddAppClicked(this, args);
    }

Class:

public class ddtestEventArgs : EventArgs
{
    // Link
    private string link;
    public string Link
    {
        get { return link; }
        set { link = value; }
    }

    public ddtestEventArgs(string link)
    {
    Link = link;
    }
}

public delegate void ddtestEventHandler(object sender, ddtestEventArgs e);
  • 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-15T10:44:49+00:00Added an answer on May 15, 2026 at 10:44 am

    Hopefully this is what you’re after. The best way to do it is to expose your controls as public properties from your user control. So, in your user control, for each drop down list add a property:

    public DropDownList DropDown1
    {
       get { return dropDownList1; }
    }
    
    public DropDownList DropDown2
    {
       get { return dropDownList2; }
    }
    

    You can do the same for any other properties you want to access on the host page:

    public string DropDown1SelectedValue
    {
       get { return dropDownList1.SelectedValue; }
       set { dropDownList1.SelectedValue = value; }
    }
    

    Then, from your host page you can access the properties through the user control:

    string value = UserControl1.DropDown1SelectedValue;
    

    or

    string value = UserControl1.DropDownList1.SelectedValue;
    

    Here’s a couple of other answered questions that you might find useful as I think (if I’ve understood correctly) this is what you’re doing:

    • Getting data from child controls loaded programmatically
    • How to change the value of a control in a MasterPage.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing one user control (webpart) in kentico. I want to pass textboxes'
You can pass special strings into jQuery's Datepicker class setDate() method like +7 which
I have a User control (because I use the same in other page, so
I have problem passing a variable from a main page containing a user control
I have a user control that contains a GridView. I pass an IEnumerable data
I need to pass a value from the onload event of a user control
You can pass a function pointer, function object (or boost lambda) to std::sort to
Using logparser you can pass on parameters to the query you'd like to run
I know you can pass arguments through the RunWorkerAsync function call when you first
I know that I can pass a string as the second parameter to the

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.