1

The following piece of code works correctly:

<span class="dysiChannelSubscription">
@if (Model.ChannelName == "ninacopes")
{
    <iframe allowtransparency="true" frameborder="0" scrolling="no" style="width:200px; height:20px;"
      src="//platform.twitter.com/widgets/follow_button.html?show_count=false&[email protected]">
    </iframe>
}
</span>

However, if I change the if to:

@if (Model.ChannelType == Fluent.Data.Enums.ChannelTypeEnum.Twitter)

It doesn't render any longer. This is in a partial view.

jQuery yields:

syntax error
<!DOCTYPE html>

I have no clue why. Model.ChannelType is of that type, and I get the twitter value purely from intellisense, which makes me wonder why this breaks at all.

2 Answers 2

2

If both sides are strings then you can try .ToString() like below.

  @if (Model.ChannelType == Fluent.Data.Enums.ChannelTypeEnum.Twitter.ToString())

If both Sides are Integer then you can try

  @if (Model.ChannelType == (int)Fluent.Data.Enums.ChannelTypeEnum.Twitter)
Sign up to request clarification or add additional context in comments.

Comments

0

Are you trying to compare the type of the model? Should it not then be something like: TypeOf(Model.ChannelType) ?

1 Comment

what? ChannelType is an enum, of type ChannelTypeEnum

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.