Solved

XSL Session variable check syntax

Posted on 2007-11-27
11
1,553 Views
Last Modified: 2013-11-18
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?
0
Comment
Question by:jandhb
  • 5
  • 4
11 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
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
0
 
LVL 1

Author Comment

by:jandhb
Comment Utility
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" />
0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
<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
0
 
LVL 1

Author Comment

by:jandhb
Comment Utility
ok, i follow that, but i thought you said i had to pass the session variable to the xslt page first?
0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
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
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 1

Author Comment

by:jandhb
Comment Utility
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 );
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 25 total points
Comment Utility
1. xsl:when is a statement inide an xsl:choose
xsl:if is equivalent to a single xsl:when without an xsl:otherwise
the adventage of xsl:if is that you don't need the xsl:choose
<xsl:choose><xsl:when test="sometest">blabla</xsl:when></xsl:choose>
and
<xsl:if test="sometest">blabla</xsl:if>
are equivalent

note that in the XSLT you best replace > with &gt;
<xsl:if test="$loginCheck &gt; 1">

2. just make sure that the value for $loginCheck gets put in the loginCheck variable in the ASP
it doesn't really matter whether it comes originally from a session variable or a request string
This line is where you pass the variable to the parameter
Args.AddParam("loginCheck", "", loginCheck );
note that I removed a space in the first argument to the method

cheers

Geert
0
 
LVL 1

Author Comment

by:jandhb
Comment Utility
I have this in my page load now...

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

look right?
0
 
LVL 60

Expert Comment

by:Geert Bormans
Comment Utility
looks right
0
 
LVL 1

Expert Comment

by:Computer101
Comment Utility
Forced accept.

Computer101
EE Admin
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Specific format 21 140
What are the big features of MVC5? 4 50
popup message 3 26
Azure Web App - See files 3 21
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now