We help IT Professionals succeed at work.
Get Started

Dynamicly loading views into a multiview / with a dynamic menu.

wdhough asked
Last Modified: 2008-01-09
hello all,

I have a project which allows a user to dynamicly create a tabbed menu, which then navigates a multiview control, and attempts to load user controls into the views of the multiview?

with me? ok..

the problrm is that the views do not seem to contain the loaded user control (which is just a label).

this is how i create the tabbed menu and load the views / controls into the multiview.

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        'Declare variables / objects
        Dim MItem As New MenuItem
        Dim strText As String
        Dim ctrl As Control = Nothing
        Dim view As New View

        'assign textbox entry to name of tab
        strText = txtTab.Text
        MItem.Text = strText

        'assign textbox value to value of tab
        MItem.Value = txtTabNo.Text

        'load user web control into empty control object
        ctrl = LoadControl("BuildForm.ascx")

        'add web user control object to view object

        'add view object to multiview object

        'create session
        Session("MultiView1") = MultiView1

    End Sub

and this is how i navigate the tabbed menu:

Protected Sub Menu1_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles Menu1.MenuItemClick
        Dim i As Integer

        i = Menu1.SelectedValue - 1

        MultiView1.ActiveViewIndex = i

    End Sub

the menu seems to navigate and change views, yet the dynamicly loaded usercontrol is not in the views.

many thanks for suggestions

Watch Question
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE