Link to home
Start Free TrialLog in
Avatar of jandhb
jandhb

asked on

XSL Session variable check syntax

I have an xsl file that is being used on a web page to display a table that contains menu links. The menu tems are like -
Help    Subscribe   Return

On certain logins which are stored in a session variable - Session["LoginCheck"] I don't want to show the "return" menu item.
Is there certain syntax to do this or go about this?
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

yes, you can set a parameter on the highest level in your stylesheet
<xsl:param name="loginCheck"/>

use that parameter in a test as $loginCheck

and pass the value of the ession variable to the stylesheet
I can show you how, if you show how you call the XSLT
Make sure you use a template processor instead of a simple transform
in order to be able to pass parameters

cheers


Geert
Avatar of jandhb
jandhb

ASKER

Geert,

When you say "use that parameter in a test as $loginCheck" can you show me how that would be done? In this particular case I just need to check if the value of that is > 1.

How would I pass the value of the session variable to the stylesheet? Right now I'm calling the XSLT with - <asp:Xml Runat="server" ID="xmlMenu" TransformSource="../navigation/menu.xslt" />
<xsl:choose>
  <xsl:when test="$loginCheck = 1">
    output the column here
  </xsl:when>
  <xsl:otherwise>
    don't output the column
  </xsl:otherwise>
</xsl:choose>

you can leave the "otherwise" clause out if you don't need it
Avatar of jandhb

ASKER

ok, i follow that, but i thought you said i had to pass the session variable to the xslt page first?
yes, that is a bit trickier when you use an XML control
Here is an article that shows you how to do that

http://www.braintrove.com/article/13

cheers

Geert
Avatar of jandhb

ASKER

I took a look at the article and have some quesions.

1. In the XSLT he is using xls:when should I use - <xsl:if test="$loginCheck > 1">

2. In my aspx this is not a query string. It is a session variable. So should I only do this without the request.querystring part?...

Args.AddParam("loginCheck ", "", loginCheck );
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jandhb

ASKER

I have this in my page load now...

XsltArgumentList Args = new XsltArgumentList();
 
    Args.AddParam("loginCheck", "", loginCheck );
 
    xmlMenu.TransformArgumentList = Args;

look right?
Forced accept.

Computer101
EE Admin