MVC easy viewport example with navigation

  1. #1

    MVC easy viewport example with navigation

    Hi all,

    I'm not able to find anywhere a simple example of a viewport in mvc razor with navigation in the north region that loads the center region of the viewport.
    I made an easy example to reproduce, this is what i got already:

    _ViewStart.vbhtml
    @Code
        Layout = "~/Views/Shared/_Layout.vbhtml"
    End Code
    _Layout.vbhtml
    @Code
    End Code
    
    
    @(Html.X().Viewport().Layout(LayoutType.Border) _
        .ItemsFromPage(Me, "~/Views/Shared/_North.vbhtml") _
        .ItemsFromSection(Me, "MainContent")
    )

    _North.vbhtml
    @(Html.X().Panel() _
        .Header(False) _
        .Region(Region.North) _
        .Border(False) _
        .Height(40) _
        .MarginSpec("0 5 0 0") _
        .Layout(LayoutType.Fit) _
        .Items.Add( _
            Html.X.Toolbar().Layout(LayoutType.HBox).Items _
            .Add(Html.X.Button() _
                    .Text("Settings") _
                    .Icon(Icon.Wrench) _
                    .Menu(Html.X.Menu.Items _
                        .Add(Html.X.MenuItem() _
                                .Text("Country") _
                                .Icon(Icon.FlagBe) _
                                .DirectEvents(Function(e)
                                                      e.Click.Url = Url.Action("ListCountry", "Country")
                                              End Function)) _
                        )) _
        )
    )
    HomeController
    Public Class HomeController
        Inherits System.Web.Mvc.Controller
    
    
        Function Index() As ActionResult
            ViewData("Message") = "Welcome to ASP.NET MVC!"
    
    
            Return View()
        End Function
    
    
    End Class
    Home/Index.vbhtml
    @Code
        ViewData("Title") = "Home - Index"
    End Code
              
    @Section MainContent
        @(Html.X.ResourceManager())
    
    
        @(Html.X().Panel() _
            .ID("PanelHome") _
            .Header(False) _
            .Region(Region.Center) _
            .Border(False) _
            .Layout(LayoutType.Fit) _
            .Padding("5") _
            .Title("PanelHome") _
            .Html("Home Panel")
        )    
    End Section
    CountryController
    Namespace MVCViewPort
        Public Class CountryController
            Inherits System.Web.Mvc.Controller
    
    
            Function ListCountry() As ActionResult
                Return View()
            End Function
    
    
        End Class
    
    
    End Namespace
    Country/ListCountry.vbhtml
    @Code
        ViewData("Title") = "ListCountry"
    End Code
    
    
    @Section MainContent
     @(Html.X().Panel() _
            .ID("PanelCountry") _
            .Header(False) _
            .Region(Region.Center) _
            .Border(False) _
            .Layout(LayoutType.Fit) _
            .Padding("5") _
            .Title("PanelCountry") _
            .Html("Country Panel")
        )    
    End Section
    The home page is displayed well, but when i click on the Country-button in the north region, the CountryController is called successfully, but the country view is not loaded in the center region and i don't receive any errors.

    Please help, because i'm already searching for a solution for over weeks.

    Thanx!
  2. #2
    Vladimir Shcheglov
    Sr. Developer
  3. #3
    Hi Vladimir,

    Thanx, i saw this one. But the way i'm doing it, isn't that possible? It's just less "complex".

    Regards
  4. #4
    ListCountry must be partial view therefore PartialViewResult must be used
    What complexity do you see in that example?
    Vladimir Shcheglov
    Sr. Developer
  5. #5
    It just seemed to me easier without passing container id's and using the rendermode.

    But i will change my code to the partial views

Similar Threads

  1. Replies: 2
    Last Post: Jul 16, 2012, 5:26 AM
  2. [CLOSED] Easy way to acces vb.net object in javascript
    By supera in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 10, 2012, 12:20 PM
  3. Replies: 1
    Last Post: Sep 22, 2011, 4:21 PM
  4. Draggable Accordion Panels Easy?
    By cgountanis in forum 1.x Help
    Replies: 2
    Last Post: Dec 16, 2009, 11:48 AM
  5. Easy way to make custom combo box
    By glenh in forum 1.x Help
    Replies: 1
    Last Post: Aug 20, 2009, 6:14 AM

Posting Permissions