PDA

View Full Version : [CLOSED] [MVC] Cascading multi Partial views



UnifyEducation
May 10, 2012, 10:01 AM
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

Daniil
May 10, 2012, 11:04 AM
Hi,

Please add "~" at the beginning of the partial view URL.

"~/Views/UserControls/HeaderCtrl.cshtml"

UnifyEducation
May 10, 2012, 11:08 AM
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.

Daniil
May 10, 2012, 11:10 AM
My fault, you should add it within the partial view.

"~/Views/UserControls/SearchCtrl.cshtml"

UnifyEducation
May 10, 2012, 1:06 PM
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)

Daniil
May 10, 2012, 1:13 PM
A North region requires Height to be set up explicitly. Please set up.

UnifyEducation
May 10, 2012, 2:10 PM
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