Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6570823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:48:16+00:00 2026-05-25T14:48:16+00:00

I have an asp.net web application. The application reads data from an xml. The

  • 0

I have an asp.net web application. The application reads data from an xml. The xml has a reference to a xslt file which takes care of the table design and alignment. I add data to the xml in a dynamic manner.
I want every alternate row of the table to have a color (say grey) for readability. I believe it can be done in xslt itself using the line of code

 <xsl:if test="(position() mod 2 = 0)">

Can someone please tell me how to do it? I have posted my xslt fully below.

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet  version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">

    <html>
      <head>
        <title>VPGate Media Mixer</title>

        <meta http-equiv="expires" content="0"/>
        <meta http-equiv="pragma" content="no-cache"/>
        <meta http-equiv="cache-control" content="no-cache, must-revalidate"/>
        <meta http-equiv="refresh" content="15"></meta>
        <script src="/Common/common.js\" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="style001.css" />
        <link rel="stylesheet" type="text/css" href="Grid.Default.css" />


      </head>

      <body class="WorkArea">       
        <div class="divSummaryHeader" id="SummaryHeader">
          <h1>Media Mixer - VPGate</h1>

          <xsl:for-each select="MMDiagnostics/Conference">
            <h1>
              Media Mixer - <xsl:value-of select="name"/>
            </h1>
          </xsl:for-each>
        </div>

        &#160;



        <div class="RadGrid RadGrid_Default" id="SummaryData" style="position:absolute;width:630px;overflow:auto">

          <table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0" >
            <tr>
              <input type="button" class="formEditBtn" id="SubBtn" value="Refresh" onclick="window.location=window.location;"/>

              </tr>
              <tr>
                <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;" colspan="2">Conference</td>
              </tr>

              <tr>
                <td>
                  <table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0" >
                    <tr>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Conference Name</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Conference Id</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Address</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Port</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Ssrc</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">No Of Participants</td>
                    </tr>

                    <xsl:for-each select="MediaMixer/Conference">
                      <!--<xsl:sort select="Name"/>-->
                      <xsl:if test="(position() mod 2 = 0)">

                        <tr class="rgAltRow SummaryTableDataRow">
                          <td valign = "top">
                            <xsl:value-of select="Name"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="ConfId"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="CompositeAddress"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="CompositePort"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="CompositeSsrc"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="NoOfParticipants"/>
                          </td>
                        </tr>
                      </xsl:if>

                      <xsl:if test="(position() mod 2 = 1)">
                        <td bgcolor="#aaaaff">
                          <tr class="rgAltRow SummaryTableDataRow">
                            <td valign = "top">
                              <xsl:value-of select="Name"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="ConfId"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="CompositeAddress"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="CompositePort"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="CompositeSsrc"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="NoOfParticipants"/>
                            </td>
                          </tr>
                        </td>
                      </xsl:if>

                    </xsl:for-each>

                  </table>
                </td>
              </tr>
            </table>

            &#160;

            <table border="0" class="rgMasterTable rgClipCells" cellspacing="1" cellpadding="1" >
              <tr>
                <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;" colspan="2">Participant</td>
              </tr>

              <tr>
                <td>

                  <table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0" >
                    <tr>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">ID 1</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">ID 2</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Participant Address</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Participant Listening Port</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">MM Listening Port</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">SSRC From Participant</td>
                      <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">SSRC From MM</td>
                    </tr>

                    <xsl:for-each select="MediaMixer/Conference/Participant">

                      <xsl:if test="(position() mod 2 = 0)">

                        <tr class="rgAltRow SummaryTableDataRow">
                          <td valign = "top">
                            <xsl:value-of select="ID1"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="ID2"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="ParticipantAddress"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="ParticipantListeningPort"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="MMListeningPort"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="SSRCFromParticipant"/>
                          </td>
                          <td valign = "top">
                            <xsl:value-of select="SSRCFromMM"/>
                          </td>
                        </tr>
                      </xsl:if>

                      <xsl:if test="(position() mod 2 = 1)">
                        <td bgcolor="#aaaaff">
                          <tr class="rgAltRow SummaryTableDataRow">
                            <td valign = "top">
                              <xsl:value-of select="ID1"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="ID2"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="ParticipantAddress"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="ParticipantListeningPort"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="MMListeningPort"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="SSRCFromParticipant"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="SSRCFromMM"/>
                            </td>

                          </tr>
                        </td>
                      </xsl:if>
                    </xsl:for-each>

                  </table>
                </td>
              </tr>
            </table>


            &#160;


            <div style="display:none">
              <iframe id="frameUpdate" name="frameUpdate" width="100%"></iframe>
            </div>


          </div>

          </body> 
    </html>
    </xsl:template>
</xsl:stylesheet>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:48:17+00:00Added an answer on May 25, 2026 at 2:48 pm

    You’re actually on the right track. Assign numbered css classes and use position() mod 2 to compute which css class to call.

    Here’s a demonstration:

    <?xml version="1.0" encoding="utf-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output version="1.0" encoding="utf-8" indent="yes" method="html"/>
    <xsl:template match="/">
      <xsl:variable name="sortValue">title</xsl:variable>
      <style type="text/css">
         .row0 { background-color: blue; }
         .row1 { background-color: red; }
       </style>
       <table border='1'>
          <tr>
             <th>ID</th>
             <th>Artist</th>
             <th>Title</th>
             <th>Album</th>
             <th>Length</th>
          </tr>
        <xsl:for-each select="*/song">
             <xsl:variable name="rowClass">
                  row <xsl:number value="position() mod 2"/> 
             </xsl:variable>     
           <tr>
             <td class="{$rowClass}"><xsl:value-of select="./@id"/></td>
             <td class="{$rowClass}"><xsl:value-of select="./artist"/></td>
             <td class="{$rowClass}"><xsl:value-of select="./title"/></td>
             <td class="{$rowClass}"><xsl:value-of select="./album"/></td>
             <td class="{$rowClass}"><xsl:value-of select="./length"/></td>
          </tr>
       </xsl:for-each>
     </table>
    

    HTH.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET web application which does the following: Reads an Excel file.
I have a asp.net web application which has a number of versions deployed on
We have an intranet asp.net web application which uses the OOTB ASP.net membership and
I have an ASP.NET web application that has a fileupload control to allow users
Background : I currently have a Web Forms, ASP.NET 3.5/C# application which I'm interested
I have an asp.net web application which I want have multilingual support now. For
Suppose you have two seperate ASP.NET Web Application projects that both need to use
We have a ASP.Net 2.0 web application up and running with the server in
I have a really simple ASP.NET web application and a web setup project that
I have a scenario where users of my ASP.NET web application submit testimonials consisting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.