我有一個側邊欄菜單,可以在li中創建div。ASP.NET if語句創建div
我遇到的問題是,如果菜單中的項目處於活動狀態,則不應在其之前創建不活動的div。即:它應該只有<li><div></div></li>
,而不是<li><div></div><div></div></li>
。
<xsl:if test="number(ParentEntityID) = 0 and EntityID!=$pCatID">
<div class="inactive">
<!--<a href="{concat('c-',EntityID,'-',SEName,'.aspx')}" style="color:black">-->
<xsl:choose>
<xsl:when test="count(child::Entity)=0">
<a href="{concat('c-',EntityID,'-',SEName,'.aspx')}" style="color:black">
<xsl:value-of select="$eName"/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="EntityID=$ParentCategoryID">
<div class="active">
<xsl:value-of select="$eName"/>
</div>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$eName"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<!--</a>-->
</div>
</xsl:if>
輸出:
<li>
**<div class="inactive">**
<div class="active">
Active item
**</div>**
</div>
</li>
<li>
<div class="inactive">
Inactive item
</div>
</li>
因此不主動DIV之外創建無效DIV,只應創建它是無效的,必須有什麼在上面的代碼改變?我把這些線放在**中,不應該在那裏。
我知道它與妥善安排test="EntityID=$ParentCategoryID"
或if
陳述有關,但無法弄清楚。
什麼變量告訴你一個項目是活動的? –
@LenielMacaferi:顯然有更多的代碼,但如何停止在活動類div之外創建的空div的一般問題? '$ ParentCategoryID'是一個活動的。 – Dave