<a href="@Url.RouteUrl("AbacusPage", new { catname = HttpUtility.UrlEncode(childitem.ChildName.Replace(' ', '-'))})" id="@childitem.ChildName.Replace(' ', '-').ToLower()">@childitem.ChildName</a>
here i replace the empty space with - but how to remove the last element i.e
-