nesting of multiviews in asp.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • archu007
    New Member
    • May 2007
    • 28

    nesting of multiviews in asp.net

    Hi frds
    i have nested multiviews and used menucontrol to navigate throught views
    this is my html code
    [code=asp]

    <asp:Menu ID="Menu1" Font-Bold="true" Orientation="Ho rizontal"
    StaticEnableDef aultPopOutImage ="False"
    OnMenuItemClick ="Menu1_MenuIte mClick" runat="server" >
    <StaticMenuItem Style CssClass=MenuCe ll ItemSpacing=0px />
    <StaticHoverSty le CssClass=MenuCe llHover/>
    <StaticSelected Style CssClass=MenuCe llSelected ItemSpacing=0px />
    </asp:Menu>
    <asp:MultiVie w ID="mView1" runat="server" ActiveViewIndex ="0">
    <asp:View ID="View1" runat="server">
    <asp:Label ID="lblView1" runat="server" Text="U r in view1"></asp:Label>
    </asp:View>
    <asp:View ID="View2" runat="server">
    <asp:Label ID="lblView2" runat="Server" Text="U r in View2"></asp:Label>
    </asp:View>
    <asp:View ID="View3" runat="server">
    <asp:Label ID="Label1" runat="Server" Text="U r in View2"></asp:Label>
    </asp:View>
    <asp:View ID="View4" runat="server">
    <table>
    <tr>
    <td valign="top">
    <asp:Menu ID="SubMenu1" runat="Server" Orientation="Ve rtical"
    StaticEnableDef aultPopOutImage ="false"
    OnMenuItemClick ="SubMenu1_Menu ItemClick">
    <StaticMenuStyl e CssClass="MenuC ell" />
    <StaticHoverSty le CssClass=MenuCe llHover />
    <StaticSelected Style CssClass=MenuCe llSelected />
    </asp:Menu>
    </td>

    <td>
    <table>
    <tr>
    <td>
    <asp:MultiVie w ID="SubMultiVie w1" runat="server">
    <asp:View ID="SubView1" runat="server">
    <asp:Label ID="lblSubView1 " runat="server" Text="u r in submenu"></asp:Label>
    </asp:View>
    <asp:View ID="SubView2" runat="server">
    <asp:Label ID="lblSubView2 " runat="server" Text="subview2" ></asp:Label>
    </asp:View>
    </asp:MultiView>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>


    </asp:View>

    </asp:MultiView>
    [/code]


    in code behind
    [code=vbnet]
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
    If Not Page.IsPostBack Then
    Dim index As Integer
    For index = 0 To mView1.Views.Co unt - 1
    Menu1.Items.Add (New MenuItem(mView1 .Views(index).I D, index.ToString( )))
    Next index
    Menu1.Items(0). Selected = True
    End If
    End Sub
    Protected Sub Menu1_MenuItemC lick(ByVal sender As Object, ByVal e As System.Web.UI.W ebControls.Menu EventArgs) Handles Menu1.MenuItemC lick
    mView1.ActiveVi ewIndex = Int32.Parse(e.I tem.Value)
    End Sub
    [/code]

    I'm able to display the main menu but i'm unable to display submenu which is in view4

    can any one giv some idea how to proceed with this
    thank u
    Archu
    Last edited by Frinavale; Oct 10 '07, 06:31 PM. Reason: Added [code] tags to make more legible
  • archu007
    New Member
    • May 2007
    • 28

    #2
    hi frs i tried n got the solution
    here is the code for codebehind

    [code=vbnet]
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
    If Not Page.IsPostBack Then
    Dim index As Integer
    Dim m As MultiView
    Dim v As View
    Dim i As Integer
    For index = 0 To mView1.Views.Co unt - 1
    Menu1.Items.Add (New MenuItem(mView1 .Views(index).I D, index.ToString( )))
    Next index
    For Each v In mView1.Views
    m = DirectCast(v.Fi ndControl("SubM ultiView1"), MultiView)
    If v.Controls.Cont ains(m) Then
    'For Each m In v.Controls.Cont ains(m)
    For i = 0 To m.Views.Count - 1
    CType(v.FindCon trol("SubMenu1" ), Menu).Items.Add (New MenuItem(m.View s(i).ID, i.ToString))
    Next
    'Next
    End If
    Next
    Menu1.Items(0). Selected = True
    End If
    End Sub
    Protected Sub Menu1_MenuItemC lick(ByVal sender As Object, ByVal e As System.Web.UI.W ebControls.Menu EventArgs) Handles Menu1.MenuItemC lick
    mView1.ActiveVi ewIndex = Int32.Parse(e.I tem.Value)
    End Sub
    Protected Sub SubMenu1_MenuIt emClick(ByVal sender As Object, ByVal e As System.Web.UI.W ebControls.Menu EventArgs) Handles SubMenu1.MenuIt emClick
    'mView1.ActiveV iewIndex = Int32.Parse(e.I tem.Value)
    Dim v As View
    For Each v In mView1.Views
    CType(v.FindCon trol("SubMultiV iew1"), MultiView).Acti veViewIndex = Int32.Parse(e.I tem.Value)
    Next
    End Sub

    [/code]
    if any modification to do plz let me know
    or any other simple way to achieve this
    thank u
    Archu
    Last edited by Frinavale; Oct 10 '07, 06:32 PM. Reason: Added [code] tags to make more legible

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Thanks for sharing the solution Archu!
      I'm glad you figured it out!

      :) :)
      -Frinny

      Comment

      Working...