Dec 19, 2016, 6:14 PM
[CLOSED] Issue with navigating through the menu
Hi Support,
I'm using Asp.net MVC and I've Issue with navigating through the menu. If I try to load page using typing URL into browser then it works fine but when navigating though the menu it hits the method on controller but doesn't render the new requested page.
I guess I'm missing something minor.
Sample code:
Layout
Thanks
I'm using Asp.net MVC and I've Issue with navigating through the menu. If I try to load page using typing URL into browser then it works fine but when navigating though the menu it hits the method on controller but doesn't render the new requested page.
I guess I'm missing something minor.
Sample code:
Layout
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width"/>
<title>@ViewBag.Title</title>
</head>
<body>
@{
var X = Html.X();
}
@(Html.X().ResourceManager())
@(X.Viewport()
.Layout(LayoutType.Anchor)
.Items(
X.Container()
.Border(true)
.ID("TopPanel")
.Items(
X.Toolbar()
.ID("ToolBarContent")
.Items(
X.ComboBox()
.ID("cmbTest1")
.Editable(false)
.Width(300)
.LabelWidth(50)
.MarginSpec("0 5 0 5")
.FieldLabel("Combo1:")
.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("Menu")
.Icon(Icon.World)
.Menu(
X.Menu()
.Icon(Icon.ArrowDown)
.Header(false)
.Items(X.MenuItem()
.ID("MenuHomeItem")
.Icon(Icon.BulletWrench)
.Text("Home")
.DirectClickUrl(@Url.Action("Index", "Home")),
X.MenuItem()
.ID("MenuFooItem")
.Icon(Icon.BulletWrench)
.Text("Foo Setup")
.DirectClickUrl(@Url.Action("Index", "Foo"))
)
)
)
),
X.Hyperlink().Text("Foo").NavigateUrl(Url.Action("Index", "Foo")),
X.Hyperlink().Text("Home").NavigateUrl(Url.Action("Index", "Home")),
X.Container()
.Width(500)
.Content(
@<text>
@RenderBody()
</text>
)
))
@RenderSection("scripts", required: false)
</body>
</html>
Home Controller public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}
Home view - Index@{
ViewBag.Title = "Home";
}
<div>
<h1>Welcome </h1>
<p>This is a home page.</p>
</div>
Foo Modelusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Ext.Net;
using Ext.Net.MVC;
namespace MvcTest.Models
{
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;
}
}
}
Foo controllerusing System;
using System.Web.Mvc;
using Ext.Net;
using Ext.Net.MVC;
using MvcTest.Models;
namespace MvcTest.Controllers
{
public class FooController : Controller
{
public ActionResult Index()
{
var 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")
}
};
return View("FooView", model);
}
[HttpPost]
public ActionResult Index(FooModel model)
{
X.Msg.Notify("Saved", "Succesfully saved").Show();
return this.Direct();
}
}
}
Foo view@model MvcTest.Models.FooModel
@{
ViewBag.Title = "Foo";
}
<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;
de.Click.EventMask.CustomTarget = "App.MainContent";
}))
)
Thanks
Last edited by fabricio.murta; Dec 21, 2016 at 9:16 PM.