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

  • Home
  • SEARCH
  • 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 3966378
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:35:35+00:00 2026-05-20T03:35:35+00:00

I have a couple user controls that are loaded by a Select Case statement.

  • 0

I have a couple user controls that are loaded by a Select Case statement. However, in the behind code file for the main page that loads these controls, none of the asp controls show up in intellisense. I had a feeling it’s because the controls are loaded conditionally. My question is what is the best way to solve this?

1) Load the controls and do a Select Case in the behind code to make them hidden or not.

2) Is there a way to say (psuedocode): LoadUserControl("UserControl1").Controls("tbTest").Text = ""

3) How can I pass a dataset to the User Control file?

4) Any other ideas?

Thanks.

Update

This allows me to load the control and access values in the sub-controls. However, the update doesn’t seem to work. Any ideas?

Private Sub SetFrequencyValues(ByVal frequency As Integer)
    Select Case frequency
        Case 2
            Dim userControl As Minutes = CType(LoadControl("Frequency/Minutes.ascx"), Minutes)
            Dim tb As TextBox = userControl.FindControl("tbMinutes")
            tb.Text = "10"
            tb.Visible = False
        Case(4)
        Case 5
        Case 6
    End Select
End Sub
  • 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-20T03:35:36+00:00Added an answer on May 20, 2026 at 3:35 am

    If you know what Controls will be displayed you can ctype them to your control

    dim uc as MyUserControl = cType(LoadUserControl("UserControl1"), MyUserControl)
    

    and your MyUserControl could have some properties, that you might want to set

    MyUserControl.Data = mySelectedData
    

    If you dont same controls, you might consider using interfaces

    Public Interface IDataForUserControl
        Public Property Data as Object
    End Interface
    

    Then you can implement this Interface, and if you load it, you could try cast it into the interface.

    If you dont have these two possibilities, you could work with ITemplates and NamingContainers.

    Dim control as new MyNamingContainerThatImplementsIDataItem
    LoadTemplate("UserControl1").instantiateIn(control)
    

    Than you could in your UserControl1 access the Data using DataBinder.

    Answer for your Update

    There might be some overriding somewhere. When are you calling your update function? Maybe the mintues.ascx is setting the same data on “load” event or something.

    You could either create a method in the “userControl” that you would access in the SetFrequencyValues method, and then it may not be touched anymore. Or you handle some event of your usercontrol

    dim userCOntrol as Minutes = Loadcontrol("Minutes.ascx")
    AddHandler userControl.load, sub(sender as Minutes, e as eventargs)
                                      sender.mytextbox.text = "10"
                                 end sub
    

    Or on prerender, what ever you want.

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

Sidebar

Related Questions

I have a couple of user controls that are loaded at runtime that contain
I currently have a couple different user controls that provide the same functionality: three
I have a couple of tables which are used to log user activity for
I'll have couple of python functions I must interface with from the assembly code.
I have a couple old services that I want to completely uninstall. How can
I have a couple of triggers on a table that I want to keep
I have a page with a couple of grids and a small form with
Some of the users of our Ruby on Rails app have complained that page
I have an image that is wrapped inside a couple of DIV elements <div
We have a lot of controls that consist of: A container with rounded borders

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.