[CLOSED] [MVC] Cascading multi Partial views

  1. #1

    [CLOSED] [MVC] Cascading multi Partial views

    Hi, I try to use Partial view in Ext.NET.

    /Home/Index.cshtml:

    @Html.X().ResourceManager().Theme(UIHelper.PORTAL_THEME).Locale("fr")
    @(Html.X().Viewport()
                   .Layout("BorderLayout")
                   .Items(vpitem => {
                       //North
                       vpitem.Add(Html.X().Panel().ContentFromPage(this, "/Views/UserControls/HeaderCtrl.cshtml")
                                        .Region(Region.North));
                       
                       //Center
                       vpitem.Add(Html.X().Panel()
                           .Region(Region.Center)
                           .ID("centerPanel")
                           .Height(600)
                           .Title("Home").Header(false)
                           .AutoDoLayout(true)
                           .Loader(new ComponentLoader {
                               AutoLoad = true,
                               // DisableCaching = true,
                               Url = "http://localhost/",
                               ReloadOnEvent = true,
                               LoadMask = {
                                   ShowMask = true,
                                   Msg = "loading..."
                               }
                           }));
    
                       //West
                       vpitem.Add(Html.X().Panel()
                            .Width(200)
                            .Region(Region.West)
                            .Layout("AccordionLayout").Split(true).Header(false)
                            .Collapsible(true)
                            .Border(true)
                            .Items(w => w.AddRange(UIHelper.LoadAllRightsByUser().ToArray()))
                           );
    
                   })
    )
    /UserControl/HeaderCtrl.cshtml

    @Html.X().Toolbar().Flat(true).Items(toolBar =>
        {
            
            toolBar.Add(Html.X().Container().ID("SearchBox").ContentFromPage(this, "Views/UserControls/SearchCtrl.cshtml"));
        })
    When I run the project, it shows this error:

    The file "/Views/UserControls/Views/UserControls/SearchCtrl.cshtml" could not be rendered, because it does not exist or is not a valid page.
    How can I put some partial view in HeaderCtrl.cshtml?
    And I have another problem: The HeaderCtrl does not show with Chrome and Firefox, but It works with IE
    Last edited by Daniil; May 10, 2012 at 2:22 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please add "~" at the beginning of the partial view URL.
    "~/Views/UserControls/HeaderCtrl.cshtml"
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    Please add "~" at the beginning of the partial view URL.
    "~/Views/UserControls/HeaderCtrl.cshtml"
    The problem is in /UserControl/HeaderCtrl.cshtml because when I add "~", nothing changed
    It displays:
    The file "~/Views/UserControls/Views/UserControls/SearchCtrl.cshtml" could not be rendered, because it does not exist or is not a valid page.
  4. #4
    My fault, you should add it within the partial view.
    "~/Views/UserControls/SearchCtrl.cshtml"
  5. #5
    Thanks for you help. But the SearchCtrl is not displayed in IE, and nothing with Chrome, Firefox
    I repost my pages:
    Views/Home/Index.cshtml:
    @Html.X().ResourceManager().Theme(UIHelper.PORTAL_THEME).Locale("fr")
    @(Html.X().Viewport()
                   .Layout("BorderLayout")
                   .Items(vpitem => {
                       //North
                       vpitem.Add(Html.X().Panel().ContentFromPage(this, "~/Views/UserControls/HeaderCtrl.cshtml")
                                        .Region(Region.North));
                       
                       //Center
                       vpitem.Add(Html.X().Panel()
                           .Region(Region.Center)
                           .ID("centerPanel")
                           .Height(600)
                           .Title("Home").Header(false)
                           .AutoDoLayout(true)
                           .Loader(new ComponentLoader {
                               AutoLoad = true,
                               // DisableCaching = true,
                               Url = "http://localhost/",
                               ReloadOnEvent = true,
                               LoadMask = {
                                   ShowMask = true,
                                   Msg = "loading..."
                               }
                           }));
    
                       //West
                       vpitem.Add(Html.X().Panel()
                            .Width(200)
                            .Region(Region.West)
                            .Layout("AccordionLayout").Split(true).Header(false)
                            .Collapsible(true)
                            .Border(true)
                           );
                   })
    )
    Views/UserControls/HeaderCtrl.cshtml:
    @Html.X().Toolbar().Flat(true).Items(toolBar =>
        {
            toolBar.Add(Html.X().Button()
                            .Icon(Icon.Help)
                            .Text("Help")
                );
            toolBar.Add(Html.X().ToolbarSeparator());
            toolBar.Add(Html.X().ToolbarFill());
            
            toolBar.Add(Html.X().Container().ID("SearchBox").ContentFromPage(this, "~/Views/UserControls/SearchCtrl.cshtml"));
        })
    Views/UserContrls/SeqrchCtrl.cshtml
    @Html.X().ComboBox().ID("SearchBox").EmptyText("Searching").Width(350)
  6. #6
    A North region requires Height to be set up explicitly. Please set up.
  7. #7
    Quote Originally Posted by Daniil View Post
    A North region requires Height to be set up explicitly. Please set up.
    Thanks. The solution in my case is ContentFromPage must be replaced by ItemsFromPage

Similar Threads

  1. [CLOSED] Multiple partial views on single page
    By machinableed in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 03, 2012, 9:06 AM
  2. [CLOSED] [Razor] using partial views
    By machinableed in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 25, 2012, 9:40 AM
  3. [CLOSED] Razor and Ext.Net base and partial views
    By boris in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 01, 2012, 3:45 PM
  4. [CLOSED] Switching between partial views on a tree panel
    By rbarr in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 24, 2011, 12:04 PM
  5. Replies: 0
    Last Post: Oct 15, 2009, 6:07 AM

Posting Permissions