Link to home
Start Free TrialLog in
Avatar of wdhough
wdhough

asked on

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

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
        Menu1.Items.Add(MItem)

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

        'add web user control object to view object
        view.Controls.Add(ctrl)

        'add view object to multiview object
        MultiView1.Views.Add(view)

        '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

thanks.
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Is this ASP.NET 2.0?

Bob
ASKER CERTIFIED SOLUTION
Avatar of madhevan_pillai
madhevan_pillai
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial