舉例,現在有一個父節點 /Order/List?groupId=1,一個子節點 /Order/Detail?orderId=3,程式需要這樣寫:
DynamicNodeProvider:
DynamicNode parentNode = new DynamicNode
{
Title = "訂單列表",
Key = "NodeA",
Controller = "Order",
Action = "List"
};
parentNode.PreservedRouteParameters.Add("groupId");
DynamicNode childNode = new DynamicNode
{
Title = "訂單明細",
ParentKey = "NodeA"
Key = "NodeB",
Controller = "Order",
Action = "Detail"
};
OrderController:
public class OrderController : Controller
{
public ActionResult List(int groupId)
{
...
}
public ActionResult List(int orderId, int groupId)
{
...
}
}
Order List HTML:
<a href="/Order/Detail?orderId=3&groupId=1" ></a>
沒有留言:
張貼留言