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.asc x")
'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. MenuEventA rgs) 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.
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.asc
'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.
Dim i As Integer
i = Menu1.SelectedValue - 1
MultiView1.ActiveViewIndex
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Bob