Solved

XSL Session variable check syntax

Posted on 2007-11-27
11
1,567 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
11 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 20363654
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
ID: 20365333
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
ID: 20365774
<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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 1

Author Comment

by:jandhb
ID: 20365787
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
ID: 20365809
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
 
LVL 1

Author Comment

by:jandhb
ID: 20366205
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
ID: 20366270
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
ID: 20366351
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
ID: 20366361
looks right
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21146866
Forced accept.

Computer101
EE Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Easy filter aspnet 2 48
asp.net mvc , views, hidden values ? 2 26
How to repeat the data 4 43
asp.net web app 3 59
There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

738 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