2013-05-22 1 views
1

저는 리 안에 div를 만드는 사이드 바 메뉴가 있습니다.ASP.NET if 문을 만드는 div

내가 가지고있는 문제는 메뉴의 항목이 활성화되어 있으면 비활성 div가 만들어지지 않아야한다는 것입니다. 예 : <li><div></div><div></div></li>이 아니라 <li><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> 

비활성 사업부가 활성 사업부의 외부에서 만든되지 않으며, 비활성 상태입니다 만 작성해야하므로 위의 코드에서 무엇을 변경해야합니까? 나는 거기에 있으면 안되는 **에 줄을 넣었습니다.

나는 test="EntityID=$ParentCategoryID" 또는 if 문을 적절하게 배열하는 것과 관련이 있지만 그냥 알아낼 수 없다는 것을 알고 있습니다.

+0

어떤 변수가 활성화되어 있는지 알려주는 변수는 무엇입니까? –

+0

@ LenielMacaferi : 분명히 더 많은 코드가 있지만, 빈 클래스 div가 활성 클래스 div 외부에서 생성되는 것을 막는 일반적인 질문은 무엇입니까? '$ ParentCategoryID'는 활성화 된 것입니다. – Dave

답변

0

이 버전은 어떻게됩니까?

<xsl:if test="number(ParentEntityID) = 0 and EntityID!=$pCatID"> 
     <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> 
       <div class="inactive"> 
       <xsl:value-of select="$eName"/> 
       </div> 
      </xsl:otherwise> 
      </xsl:choose> 
     </xsl:otherwise> 
     </xsl:choose> 
    </xsl:if> 
+0

감사합니다. 방금 비활성 div가 비활성 항목에서 누락되었습니다. – Dave

+0

코드가 변경되었습니다 ... :) –

+0

Perfect! 'test = "count (child :: Entity) = 0' 문을 사용하지 말고 비활성 div를 배치하여 작업을 수행했는지 확인하십시오. 그러나 문제가 해결되지 않았습니다 :) D 고맙습니다. ! – Dave