我在这里动态创建了一组锚标签。但是在前端,锚点在我设置href之前有一个包含“/ usercontrols /”的href。假设href设置为测试在前端它显示为www.blah.com/usercontols/test,它应该只是www.blah.com/test
foreach (Node child in parentNode.Children)
{
if (child.Name.Contains("contact"))
break;
var hidden = "";
var deleted = "0";
var naviHide = child.GetProperty("umbracoNaviHide");
var userDeleted = child.GetProperty("userDeleted");
if (naviHide != null)
{
hidden = naviHide.Value;
if (userDeleted != null)
deleted = userDeleted.Value;
// nav.InnerText += naviHide.Value;
if (hidden != "1" && deleted !="1")
{
var anchor = new HyperLink();
var title= child.GetProperty("title");
//anchor.Text=child.Id.ToString();
if (!string.IsNullOrWhiteSpace(title.Value))
anchor.Text = title.Value;
else
{
var name = child.Name.Split('_');
anchor.Text = name[1];
}
if (child.Id == Node.GetCurrent().Id)
anchor.CssClass = "current";
else
anchor.CssClass = "navigation";
if (!host.Contains("testcms"))
{
if (!string.IsNullOrWhiteSpace(child.GetProperty("umbracoUrlAlias").Value))
anchor.NavigateUrl = child.GetProperty("umbracoUrlAlias").Value;
else
anchor.NavigateUrl = child.NiceUrl;
}
else
{
var id = child.Id.ToString();
anchor.NavigateUrl = id;
//anchor.NavigateUrl=anchor.NavigateUrl.Replace("usercontrols", "");
}
nav.Controls.Add(anchor);
}
}
}
我该怎么做才能确保链接中没有显示?有没有javascript解决方案或我可以在c#代码中做的事情。