Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

XSL Session variable check syntax

Posted on 2007-11-27
11
Medium Priority
?
1,584 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
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 100 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

916 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