Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • vladzebu 59 posts 346 karma points
    Jul 20, 2009 @ 11:22
    vladzebu
    0

    Umbraco QueryString

    I want to take the all QueryString of the context in an xslt file .

    Is something similar with :

     

    public static string RequestQueryString(string key); 

    or i have to build my own helper to get it. 

    Best regards , Vlad

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 20, 2009 @ 11:26
    Jan Skovgaard
    2

    I am not sure why you are trying to use some C# code in an XSLT file? I does not make sense I think? :)

    Why don't you just use the built in XSLT extension to get the value from your Querystring?

    You should be able to write something like this

    <xsl:value-of select="umbraco.library:RequestQueryString('Yourstring')"/>

    Hope this is what you mean?

    /Jan

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Jul 20, 2009 @ 11:26
    Peter Dijksterhuis
    2

    Hi,

    you can use the umbraco.library for that. That allready has a function: RequestQueryString(string key)

    <xsl:value-of select="umbraco.library:RequestQueryString('yourkey')"/>

    HTH,

    PeterD

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Jul 20, 2009 @ 11:33
    Warren Buckley
    0

    As Jan & PeterD have suggested this is the best way to do it - this has been documented in the WIKI
    http://our.umbraco.org/wiki/reference/umbracolibrary/requestquerystring

    Also Vlad you may find browsing through the WIKI useful, especially the umbraco.library section
    http://our.umbraco.org/wiki/reference/umbracolibrary

  • vladzebu 59 posts 346 karma points
    Jul 20, 2009 @ 11:37
    vladzebu
    0

     <xsl:value-of select="umbraco.library:RequestQueryString('yourkey')"/>

    it's the same with

    public static string RequestQueryString(string key); 

       I copy/paste from umbraco.dll  . 

       I want to take the all Querystring , not just the value of a single key . 

       http://server/path/program?field1=value1&field2=value2&field3=value3...

    i want to return from this url : field1=value1&field2=value2&field3=value3...

    BR,

    Vlad

  • Petr Snobelt 923 posts 1535 karma points
    Jul 20, 2009 @ 11:42
    Petr Snobelt
    1

    You can create your own xslt extension with Request.QueryString.ToString()

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Jul 20, 2009 @ 12:01
    Peter Dijksterhuis
    103

    Try this instead, it returns the complete querystring:

    <xsl:value-of select="umbraco.library:RequestServerVariables('QUERY_STRING')"/>
  • Simon Justesen 436 posts 203 karma points
    Jul 20, 2009 @ 13:22
    Simon Justesen
    1

    You can extend your xslt with your own C# methods - see this example:
    http://www.simm.dk/umbraco-corner/articles/using-c-sharp-inside-your-xslt.aspx

  • Simon Justesen 436 posts 203 karma points
    Jul 20, 2009 @ 13:56
    Simon Justesen
    2

    I just created a wiki-page instead (same info, better overview):
    http://our.umbraco.org/wiki/reference/xslt/extend-your-xslt-with-custom-functions

  • Petr Snobelt 923 posts 1535 karma points
    Jul 20, 2009 @ 15:30
    Petr Snobelt
    0

    Thanks Simon for wiki article,

    I know how to use c# in xslt, but trick with msxml:assembly is new for me :-)

  • noorali 1 post 21 karma points
    May 23, 2012 @ 19:36
    noorali
    0

    Hi all, can you help me

    I have a dataset which is a simple dataset right now based on breakfast.

     

    breakfast.xml

     

    <?xml version="1.0" encoding="iso-8859-1"?><!-- Edited by XMLSpy® -->

     

    <breakfast_menu> 

     

    <food>   

     

    <name>BelgianWaffles</name>

     

    <price>$5.95</price> 

     

    description>two of our famous Belgian Waffles with plenty of real maple syrup</description>

     

    <calories>650</calories> 

     

    </food> 

     

    <food>

     

    <name>StrawberryBelgianWaffles</name>

     

    <price>$7.95</price>

     

    <description>light Belgian waffles covered with strawberries and whipped cream</description>

     

    <calories>900</calories>

     

    /food>

     

    food>

     

    name>Berry-Berry Belgian Waffles</name>

     

    <price>$8.95</price>    <description>light Belgian waffles covered with an assortment of fresh berries and whipped cream</description>    <calories>900</calories>  </food>  <food>    <name>French Toast</name>    <price>$4.50</price>    <description>thick slices made from our homemade sourdough bread</description>    <calories>600</calories> 

     

    </food>

     

    <food> 

     

    <name>Homestyle Breakfast</name> 

     

    <price>$6.95</price> 

     

    <description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description>    <calories>950</calories> 

     

    </food></breakfast_menu>

     

    breakfast.xslt

     

    <?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited by XMLSpy® --><html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">

      <body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">    <xsl:for-each select="breakfast_menu/food">      <div style="background-color:teal;color:white;padding:4px">        <span style="font-weight:bold">

              <a target="_blank">           

     

    <xsl:attribute name="href">Default3.aspx?Prac=<xsl:value-of select="name"/></xsl:attribute>

     

    <xsl:value-of select="name"/></a> 

     

    </span>

     

    </div>

     

    </xsl:for-each>

     

    </body></html>

     

    Default2.aspx.cs

     

    using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Xml;using System.Xml.Xsl;using System.Xml.XPath;

    using System.Data;using System.Configuration;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls; public partial class Default2 : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {

     

      XPathDocument myxmlDoc = new XPathDocument(Server.MapPath(".\\App_data\\breakfast.xml"));        XslCompiledTransform myXSLTransform = new XslCompiledTransform();        myXSLTransform.Load(Server.MapPath(".\\App_data\\breakfast.xslt")); ;        myXSLTransform.Transform(Server.MapPath(".\\App_data\\breakfast.xml"), null, Response.Output);

     

    }

     

     

     

     

     

    breakfastmy.xml

     

    <?xml version= "1.0"?><?xml-stylesheet type="text/xsl" href="breakfastmy.xslt"?><breakfast_menu>  <food>    <name>BelgianWaffles</name>    <price>$5.95</price>    <description>two of our famous Belgian Waffles with plenty of real maple syrup</description>    <calories>650</calories>  </food>  <food>    <name>StrawberryBelgianWaffles</name>    <price>$7.95</price>    <description>light Belgian waffles covered with strawberries and whipped cream</description>    <calories>900</calories>  </food>  <food>    <name>Berry-Berry Belgian Waffles</name>    <price>$8.95</price>    <description>light Belgian waffles covered with an assortment of fresh berries and whipped cream</description>    <calories>900</calories>  </food>  <food>    <name>French Toast</name>    <price>$4.50</price>    <description>thick slices made from our homemade sourdough bread</description>    <calories>600</calories>  </food>  <food>    <name>Homestyle Breakfast</name>    <price>$6.95</price>    <description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description>    <calories>950</calories>      </food></breakfast_menu>

     

     

     

    breakfastmy.xslt

     

    <?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited by XMLSpy® --><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">          <xsl:template match="/">    <xsl:param name="brkname" select="/in:inputs/in:param[@name='brkname]'"/>          <!--<xsl:variable name="queryStringBase" select="'?qualification=', $qualification, '&studymode=', $studyMode,'&subject=', $subject, '&pagesize=', $pageSize)" />          <brkname>    <xsl:value-of select="$brkname"/>    </brkname>-->       <html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">

          <body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">        <table border="1">            <tr bgcolor="#9acd32">              <th>DESCRIPTION</th>              <th>CALORIES</th>              <th>PRICE</th>            </tr>          <xsl:for-each select="breakfast_menu/food">                        <!--if i click on the first kind of breakfast which is belgianwaffles and write it here explicitly it shows the details for this kind of breakfatst but if pass it through xsl:param brkname it doesnt return anythng-->         

     

      <!--<xsl:if test="name= 'BelgianWaffles'">-->

     

    <xsl:if test="name=$brkname">

     

    <tr> <td><xsl:value-of select="description"/>               

     

    </td>                <td>                 

     

    <xsl:value-of select="calories"/>

     

    </td>

     

    <td>                    <xsl:value-of select="price"/>                  </td>              </tr>            </xsl:if>          </xsl:for-each>

            </table>      </body>    </html>    </xsl:template></xsl:stylesheet>

     

    Default3.aspx.cs

     

    using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Xml.Xsl;using System.IO;using System.Xml;using System.Xml.Xsl;using System.Xml.XPath;public partial class Default3 : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        string brkname = Request.QueryString["prac"];        XsltArgumentList argList = new XsltArgumentList();        XPathDocument myxmlDoc2 = new XPathDocument(Server.MapPath(".\\App_data\\breakfastmy.xml"));        XslCompiledTransform myXSLTransform2 = new XslCompiledTransform();        argList.AddParam("brkname", "", Request.QueryString["prac"]);

            myXSLTransform2.Load(Server.MapPath(".\\App_data\\breakfastmy.xslt"));        myXSLTransform2.Transform(Server.MapPath(".\\App_data\\breakfastmy.xml"), argList, Response.Output);               }}

     

     

     

     

     

    Actullay my problem is that i m trying to pass value of breakfast name from default2.aspx page through querystring to default3.aspx page and from there i extract value of breakfast name through request.querystring which is stored in brkname variable.but my problem is that i have to pass this brkname to xslt page and filter the records and only show the details of the breakfast that have come in from querystring. While being specific brkname added in the parameter in xslt doesnt get the value .How can i do this ?Please provide help in this issue.

     

    I wil greatfull to you.

Please Sign in or register to post replies

Write your reply to:

Draft