0

I am trying to modify a cshtml page to only run the code if the URL has specific value. I have very little experience in coding C#, I only dabble in it when I need to make changes on pages in our purchased app.

my URL will be either https://www.website.com/subsite/info#tab1 or https://www.root.com/subsite/info#tab1

what is am trying to do is generate a specific portion of the page if it is tab1.

<script type="text/html" id="page">
<div id="div1-partial">
<section class="section_class">
<!-- my attempt at conditional logic -->
@{string CurrentURL = Request.Url.AbsoluteUri;}

@if (CurrentURL.Contains("tab1"))
{
  <div id="div2">
  </div>
}

</section
</div>
</script

So I would only want div2 to show on the page if the URL contains tab1. This doesn't seem to do it. any help pointing me in the right direction wold be much appreciated.

Bob Klimes
  • 155
  • 8

0 Answers0