I am using code like this to detect the browser and apply a condition to display or not display <label>:
@{
var settings = Model.PartFieldDefinition.Settings.GetModel();
System.Web.HttpBrowserCapabilitiesBase theBrow = Request.Browser;
}
<fieldset>
@{
   if ((theBrow.Browser == "IE") && (theBrow.MajorVersion < 10)) 
   {
       @:<label>@Model.DisplayName</label>
       @://Some Code for inputs
   }
   else 
   {
        @://Some Code for inputs
   }
}
</fieldset>
I have been trying to figure out if I can (and if so, how) I could utilize this logic to detect what path in the website the user is in to display or not display <label>
For example, on any other path I want the label displayed. However, for the pages under ~/Services (the path), I want to be able to hide the label.
It's a little bit more complicated than that. The code is in an editor template that gets used all over the site. If I use CSS in the editor template to "hide" the label I will affect all the pages. I was hoping with the above logic I can avoid that and only apply my logic on certain pages under a path.
Thanks.
Update I have tried the following:
@{
    string CurrentURL = Request.ApplicationPath;
}
<fieldset>
@{
    if ((CurrentURL == "Services")) // also tried "/Services"
    // rest of code left out for brevity
}
but the labels are hidden on all pages, even outside the path "~/Services". Am stuck on the syntax.
Found answer
I did the following:
@{
    string CurrentURL = Request.Url.AbsoluteUri;
}
<fieldset>
@{
    if (CurrentURL.Contains("Services"))
}
and it worked. I don't know if anyone can comment, but which would be better to use: Request.Url.AbsoluteUri or Request.Url.ToString() (both of which work)?
