Copied to clipboard

Flag this post as spam?

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


  • syn-rg 282 posts 425 karma points
    Jan 18, 2013 @ 00:12
    syn-rg
    0

    How to add the query string to the XSLTsearch results page URL

    How can I add the query string to the XSLTsearch results URL?

    When I click on the submit button, I would like the query string to display in the URL:
    e.g /search-results.aspx?search=red

    <xsl:if test="$searchBoxLocation='TOP' or $searchBoxLocation='BOTH'">
      <div class="xsltsearch_form">
        <input name="search" type="text" class="input">
          <xsl:attribute name="value">
            <xsl:value-of select="$unescapedSearch"/>
          </xsl:attribute>
        </input>
        <xsl:text>&nbsp;</xsl:text>
        <input type="submit" class="submit">
          <xsl:attribute name="value">
            <xsl:value-of select="$dictionaryButton-Search"/>
          </xsl:attribute>
        </input>
      </div>
    </xsl:if>

    Can anyone help me out?

    Cheers, JV

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jan 18, 2013 @ 00:20
    Chriztian Steinmeier
    0

    Hi JV,

    Is the method set to 'get' on the form tag? (i.e. <form method="get"> )

    /Chriztian

  • syn-rg 282 posts 425 karma points
    Jan 18, 2013 @ 00:38
    syn-rg
    0

    Hi Chriztian,

    It's currently set in my template as <form id="form1" runat="server"> which on the front end the method sets to "post"

     

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jan 18, 2013 @ 07:56
    Chriztian Steinmeier
    0

    Hi JV,

    And what happens if you specifically add the method="get" attribute to that tag? (I hardly ever use the server-side webform so wouldnt know how it affects your page).

    XSLTsearch works with either method so you should be able to get it working, somehow.

    /Chriztian

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jan 18, 2013 @ 18:50
    Douglas Robar
    0

    Hi, JV,

    Chriztian is quite right, you don't need a server-side form for XSLTsearch to work so you can remove the runat="server" portion of the <form> tag and save some viewstate overhead. He's also correct that you can use either action="post" (which uses form fields so you don't see anything on the querystring) or action="get" (whcih uses and displays urls with querystring values). 

    One last tid-bit... even if you're using action="post" (as I typically do) you can always manually supply a search term on the querystring and it will work. This is handy for emails, for instance, when you want to send a link to a specific search result. mydomain.com/search.aspx?search=JV would show results for 'JV'. Though if you're using action="post" you won't see the querystring used after the initial search. Still, handy though and I've found it quite helpful.

    cheers,
    doug. 

Please Sign in or register to post replies

Write your reply to:

Draft