Display code based on tag name in _ProductTags.cshtml

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 1 an
Hi there
I would like to display a certain tag in a special way but It´s not working the way I´d like.

This is the code that displays the list of Product Tags
@if (Model.Count > 0)


I was hoping I could add a code at the bottom that would display only certain html code if there is a tag called SpecialTag like this:
@if (Model.Name = SpecialTag)


But this is not working, how would I display code if there is a tag called SpecialTag?
Il y a 1 an
bvWebmaster wrote:

@if (Model.Name = SpecialTag)

the model is a list of ProductTagModel
try with this
@if (Model[i].Name = SpecialTag)
Il y a 1 an
Thank you for your reply.

That gives me the error:
The name 'i' does not exist in the current context


But if I put that code within this loop:
@for (var i = 0; i < Model.Count; i++)


Than I get the error:
The name 'SpecialTag' does not exist in the current context
Il y a 1 an
there is already code example at _ProductTags.cshtml page

just put conditions like this inside for the loop
@if(Model[i].Name == "SpecialTag")
//you code here
Il y a 1 an
Thank you very much Rashed, I had tried every version of using one = or two == and wrapping in single quotes or double quotes, but I had not yet tried the right way that you pointed out, using two == and wrapping the tag in double quotes.

Thanks for your help!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.