hiding a div tag - not working

I have the following code.  It is some to hide a div based on a value in my model...but it seems to hide it all the time...something must be wrong with the syntax.

Here is the code:
  <div class="step-content">
                                            <div class="@(Model.SiteName.Contains("subscribersite_")?"hidden":"step-pane active sample-pane alert")" data-step"1">

Open in new window

This should only hide the dive tag when the model contains that value.  It does hide it...but it also hides it when it doesnt contain that value.

I am using built in bootstrap to change the class...but a display none approach is fine as well.

LVL 11
Robb HillSenior .Net DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Is this a problem of the page not rendering out the correct class
The class not doing what it is supposed to do i.e. hide the div

In other words if SiteName contains subscribersite_ do you get this
<div class="hidden" data-step="1">

Open in new window

And if SiteName DOES NOT contain subscribersite_ do you get this
<div class="step-pane active sample-pane alert" data-step="1">

Open in new window

Are we dealing with a server side logic issue or a client side styling issue?
Robb HillSenior .Net DeveloperAuthor Commented:
when i render the html it indicates
<div class="hidden" data-step="1">

which is the html it should render since it does not contain subscribersite_

yet it still hides the div...

It hides div no matter what
NerdsOfTechTechnology ScientistCommented:
add ! (NOT operator) to the IF statement:

<div class="@(!Model.SiteName.Contains("subscribersite_")?"step-pane active sample-pane alert":"hidden")" data-step"1">

Open in new window

With NOT, the meaning of the IF becomes:

IF NOT Model.SiteName.Contains("subscribersite_") THEN render visible ELSE render invisible

Technically you could reverse the true/false as a substitution for the NOT operator; yet to match your logic, you should use the NOT operator (!).

<div class="@(Model.SiteName.Contains("subscribersite_")?"hidden":"step-pane active sample-pane alert")" data-step"1">

Open in new window

What's confusing is that you indicate that the HTML output was correct as "hidden" when logically you would think the hidden class makes the div invisible; therefore, I would presume that the hidden should be the output to hide the div.

Also, what is the value of SiteName at the time of testing?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.