Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Umbraco:检查当前页面是否是id或名称为';xxx和x27;_C#_Asp.net Mvc_Razor_Umbraco_Umbraco7 - Fatal编程技术网

C# Umbraco:检查当前页面是否是id或名称为';xxx和x27;

C# Umbraco:检查当前页面是否是id或名称为';xxx和x27;,c#,asp.net-mvc,razor,umbraco,umbraco7,C#,Asp.net Mvc,Razor,Umbraco,Umbraco7,我需要检查当前页面是否是另一页面的子页面 var myPage = Umbraco.Content(1086); if(Model.IsChildOf(myPage)) { } ?? 我想这就是你要问的:——) 或 我用了选项1,谢谢 if(Model.Path.Contains("1086")) { //.. the page is a child of the node with id == 1086 } var myPage = Umbraco.Content(1086);

我需要检查当前页面是否是另一页面的子页面

var myPage = Umbraco.Content(1086);
if(Model.IsChildOf(myPage)) {  }   ??

我想这就是你要问的:——)


我用了选项1,谢谢
if(Model.Path.Contains("1086")) {
  //.. the page is a child of the node with id == 1086
}
var myPage = Umbraco.Content(1086);
if(Model.Path.Contains(myPage.Id.ToString())) { 
  // It's a child!
}