Aug 22, 2016, 7:31 PM
[CLOSED] IFrame alternative using partial view
Hi Support,
I'm working on application where I need to render basic shell of application on startup which contains few controls and Menu. And all the other pages should be render inside the loaded shell's Main content container.I was able to load the partial view, However when I do post operation it post back whole page. How do I make it behave like IFrame so whole page doesn't postback ?
Attached is sample code to reproduce the issue.
Shell Controller:
Foo Controller
Thanks
I'm working on application where I need to render basic shell of application on startup which contains few controls and Menu. And all the other pages should be render inside the loaded shell's Main content container.I was able to load the partial view, However when I do post operation it post back whole page. How do I make it behave like IFrame so whole page doesn't postback ?
Attached is sample code to reproduce the issue.
Shell Controller:
public class ShellController : Controller
{
//
// GET: /Test/
[HttpGet]
public ActionResult Shell()
{
return View();
}
[HttpGet]
public ActionResult Home()
{
return new Ext.Net.MVC.PartialViewResult
{
ContainerId = "MainContent",
WrapByScriptTag = false,
ViewName = "Home"
};
}
}
Shell.cshtml@{
ViewBag.Title = "Index";
Layout = null;
var X = Html.X();
}
@(Html.X().ResourceManager())
@(
X.Viewport()
.Layout(LayoutType.Anchor)
.Items(
X.Container()
.Region(Ext.Net.Region.North)
.Border(true)
.ID("TopPanel")
.Items(
X.Toolbar()
.ID("ToolBarContent")
.Items(
X.ComboBox()
.ID("cmbTest1")
.Editable(false)
.Width(250)
.LabelWidth(30)
.MarginSpec("0 5 0 5")
.FieldLabel("Test1:")
.Items(
new Ext.Net.ListItem("Item 1", "1"),
new Ext.Net.ListItem("Item 2", "2")
)
)
,
X.Toolbar()
.ID("ToolBarMenu")
.Items(
X.Button()
.ID("MenuGlobalSetupButton")
.Text("GlobalSetup")
.Icon(Icon.World)
.Menu(
X.Menu()
.Icon(Icon.ArrowDown)
.Header(false)
.Items(
X.MenuItem()
.ID("MenuFooItem")
.Icon(Icon.BulletWrench)
.Text("Foo Setup")
.DirectClickUrl("../Foo/Index")
)
)
)
),
X.Container()
.ID("MainContent")
.Loader(
X.ComponentLoader()
.Mode(LoadMode.Script)
.LoadMask(loadmask => { loadmask.ShowMask = true; })
.Url(Url.Action("Home"))
.Params(new { containerId = "MainContent" })
)
)
)
Home.cshtml@{Layout = null;}
<div >
<h1>Welcome </h1>
<p>This is a test page.</p>
</div>
Foo Controller
public class FooController : Controller
{
[HttpGet]
public ActionResult Index()
{
return new Ext.Net.MVC.PartialViewResult
{
ContainerId = "MainContent",
ViewName = "FooView",
RenderMode = RenderMode.AddTo,
WrapByScriptTag = false,
Model = new FooModel()
{
TextValue = "TextValue",
DateTimeValue = DateTime.Now,
ComboValue1 = new ListItem("Item 1", "1"),
ComboValue2 = new ListItem[]
{
new ListItem("Item 1", "1"),
new ListItem("Item 5", "5")
},
ComboValue3 = "1",
CheckboxValue = true,
NumberValue = 1,
MultiSliderValue = new int[] {10, 40, 70},
Data = new ListItem[]
{
new ListItem("Item 1", "1"),
new ListItem("Item 2", "2"),
new ListItem("Item 3", "3"),
new ListItem("Item 4", "4"),
new ListItem("Item 5", "5")
}
}
};
}
[HttpPost]
public ActionResult Index(FooModel model)
{
X.Msg.Notify("Saved", "Successfully saved").Show();
return this.Direct();
}
}
FooView.cshtml@model MIPS.Models.FooModel
@{
ViewBag.Title = "Model Bind";
Layout = null;
}
<h1>Foo</h1>
@(
Html.X().FormPanel()
.Layout(LayoutType.Form)
.Width(350)
.FieldDefaults(d =>
{
d.LabelWidth = 150;
})
.BodyPadding(10)
.Frame(true)
.Items(
Html.X().TextFieldFor(m => m.TextValue),
Html.X().DateFieldFor(m => m.DateTimeValue),
Html.X().ComboBoxFor(m => m.ComboValue1).Items(Model.Data),
Html.X().ComboBoxFor(m => m.ComboValue2).Items(Model.Data),
Html.X().ComboBoxFor(m => m.ComboValue3).Items(Model.Data),
Html.X().CheckboxFor(m => m.CheckboxValue),
Html.X().NumberFieldFor(m => m.NumberValue),
Html.X().SliderFor(m => m.MultiSliderValue)
)
.Buttons(
Html.X().Button()
.Text("Save")
.Icon(Icon.Disk)
.FormBind(true)
.DirectEvents(de =>
{
de.Click.Url = Url.Action("Index");
de.Click.Method = HttpMethod.POST;
de.Click.EventMask.ShowMask = true;
}))
)
Foo Model
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Ext.Net;
using Ext.Net.MVC;
public class FooModel
{
[Field(FieldLabel = "TextField")]
public string TextValue
{
get;
set;
}
[Field(FieldLabel = "DateField")]
public DateTime DateTimeValue
{
get;
set;
}
[Field(FieldLabel = "ComboBox 1")]
public ListItem ComboValue1
{
get;
set;
}
[Field(FieldLabel = "ComboBox 2")]
public IEnumerable<ListItem> ComboValue2
{
get;
set;
}
[Field(FieldLabel = "ComboBox 3")]
public string ComboValue3
{
get;
set;
}
[Field(FieldLabel = "CheckBox")]
public bool CheckboxValue
{
get;
set;
}
[Field(FieldLabel = "NumberField")]
public int NumberValue
{
get;
set;
}
[Field(FieldLabel = "MultiSlider")]
public int[] MultiSliderValue
{
get;
set;
}
public IEnumerable<ListItem> Data
{
get;
set;
}
}
Thanks
Last edited by fabricio.murta; Oct 10, 2016 at 8:56 PM.