vPath cutting off path location name?

Discussion in 'ASP General' started by zz12, Jun 14, 2007.

  1. zz12

    zz12 Guest

    Hello. We have a SearchResults.asp page that returns a list of asp pages
    that are associated with the user's search parameters that they type in in a
    search page called something like Search.asp. We noticed that the last line
    in the following rs("vpath") value lists the path up until the first blank
    of either a folder or file name and cuts off the rest of the path's text
    name. Does anyone know how to have the vpath list the entire path name even
    including spaces if there are any?

    <%
    Dim sSearchString
    Dim oQuery

    sSearchString = Request.Form("query")

    Const SEARCH_CATALOG = "web" 'remember to change this

    Set oQuery = Server.CreateObject("IXSSO.Query")
    oQuery.Catalog = SEARCH_CATALOG
    oQuery.Query = "@all " & sSearchString & " AND NOT #path *_* AND NOT #path
    *downloads* AND NOT #path *images* AND NOT #filename *.class AND NOT
    #filename *.asa AND NOT #filename *.css AND NOT #filename *postinfo.html"
    oQuery.MaxRecords = 200
    oQuery.SortBy = "rank[d]"
    oQuery.Columns = "DocAuthor, vpath, doctitle, FileName, Path, Write, Size,
    Rank, Create, Characterization, DocCategory"
    Set rs = oQuery.CreateRecordSet("nonsequential")

    Response.write "<a href=" & rs("vpath") & "> <font color='#49698D' size='2'
    style='arial'><b>" & rs("doctitle") & "</b></font></a><br>"
    %>

    Thanks in advance.
    zz12, Jun 14, 2007
    #1
    1. Advertising

  2. zz12 wrote on Wed, 13 Jun 2007 16:41:08 -0700:

    > Hello. We have a SearchResults.asp page that returns a list of asp pages
    > that are associated with the user's search parameters that they type in in
    > a search page called something like Search.asp. We noticed that the last
    > line in the following rs("vpath") value lists the path up until the first
    > blank of either a folder or file name and cuts off the rest of the path's
    > text name. Does anyone know how to have the vpath list the entire path
    > name even including spaces if there are any?
    >
    > <%
    > Dim sSearchString
    > Dim oQuery
    >
    > sSearchString = Request.Form("query")
    >
    > Const SEARCH_CATALOG = "web" 'remember to change this
    >
    > Set oQuery = Server.CreateObject("IXSSO.Query")
    > oQuery.Catalog = SEARCH_CATALOG
    > oQuery.Query = "@all " & sSearchString & " AND NOT #path *_* AND NOT #path
    > *downloads* AND NOT #path *images* AND NOT #filename *.class AND NOT
    > #filename *.asa AND NOT #filename *.css AND NOT #filename *postinfo.html"
    > oQuery.MaxRecords = 200
    > oQuery.SortBy = "rank[d]"
    > oQuery.Columns = "DocAuthor, vpath, doctitle, FileName, Path, Write, Size,
    > Rank, Create, Characterization, DocCategory"
    > Set rs = oQuery.CreateRecordSet("nonsequential")
    >
    > Response.write "<a href=" & rs("vpath") & "> <font color='#49698D'
    > size='2' style='arial'><b>" & rs("doctitle") & "</b></font></a><br>"
    > %>


    You need to put quotes around the path, and I'd recommend URL encoding them
    too. For completeness I'd also recommend HTML encoding doctitle just in case
    there are any characters that might cause problems (however, if you know
    this is already in HTML format you can remove the Server.HTMLEncode function
    call)

    Response.write "<a href=""" & Server.URLEncode(rs("vpath")) & """> <font
    color='#49698D'
    size='2' style='arial'><b>" & Server.HTMLEncode(rs("doctitle")) &
    "</b></font></a><br>"

    Notice the "" before and after the path value, this writes a " at those
    positions

    That should do it. The reason the path was being cut at the space is because
    without the href value being quote the browser has to use spaces as the
    attribute delimiters, eg.

    <a href=my path>

    the href value becomes "my", because "path" could be another attribute name.
    If you had

    <a href="my path">

    then the browser will know that "my path" is the entire path. However,
    spaces in URLs are not allowed, so you do this:

    <a href="my+path">

    and everthing works properly. Server.URLEncode will do all the work of
    ensuring that the vpath value is correctly presented for URL use, replacing
    all non-legal chars with URL entities.

    Dan
    Daniel Crichton, Jun 14, 2007
    #2
    1. Advertising

  3. zz12

    zz12 Guest

    That fixed it. You are awesome. Thanks a bunch Daniel. Much appreciated.

    Take cares :)


    "Daniel Crichton" <> wrote in message
    news:...
    > zz12 wrote on Wed, 13 Jun 2007 16:41:08 -0700:
    >
    >> Hello. We have a SearchResults.asp page that returns a list of asp pages
    >> that are associated with the user's search parameters that they type in
    >> in
    >> a search page called something like Search.asp. We noticed that the last
    >> line in the following rs("vpath") value lists the path up until the first
    >> blank of either a folder or file name and cuts off the rest of the path's
    >> text name. Does anyone know how to have the vpath list the entire path
    >> name even including spaces if there are any?
    >>
    >> <%
    >> Dim sSearchString
    >> Dim oQuery
    >>
    >> sSearchString = Request.Form("query")
    >>
    >> Const SEARCH_CATALOG = "web" 'remember to change this
    >>
    >> Set oQuery = Server.CreateObject("IXSSO.Query")
    >> oQuery.Catalog = SEARCH_CATALOG
    >> oQuery.Query = "@all " & sSearchString & " AND NOT #path *_* AND NOT
    >> #path
    >> *downloads* AND NOT #path *images* AND NOT #filename *.class AND NOT
    >> #filename *.asa AND NOT #filename *.css AND NOT #filename *postinfo.html"
    >> oQuery.MaxRecords = 200
    >> oQuery.SortBy = "rank[d]"
    >> oQuery.Columns = "DocAuthor, vpath, doctitle, FileName, Path, Write,
    >> Size,
    >> Rank, Create, Characterization, DocCategory"
    >> Set rs = oQuery.CreateRecordSet("nonsequential")
    >>
    >> Response.write "<a href=" & rs("vpath") & "> <font color='#49698D'
    >> size='2' style='arial'><b>" & rs("doctitle") & "</b></font></a><br>"
    >> %>

    >
    > You need to put quotes around the path, and I'd recommend URL encoding
    > them too. For completeness I'd also recommend HTML encoding doctitle just
    > in case there are any characters that might cause problems (however, if
    > you know this is already in HTML format you can remove the
    > Server.HTMLEncode function call)
    >
    > Response.write "<a href=""" & Server.URLEncode(rs("vpath")) & """> <font
    > color='#49698D'
    > size='2' style='arial'><b>" & Server.HTMLEncode(rs("doctitle")) &
    > "</b></font></a><br>"
    >
    > Notice the "" before and after the path value, this writes a " at those
    > positions
    >
    > That should do it. The reason the path was being cut at the space is
    > because without the href value being quote the browser has to use spaces
    > as the attribute delimiters, eg.
    >
    > <a href=my path>
    >
    > the href value becomes "my", because "path" could be another attribute
    > name. If you had
    >
    > <a href="my path">
    >
    > then the browser will know that "my path" is the entire path. However,
    > spaces in URLs are not allowed, so you do this:
    >
    > <a href="my+path">
    >
    > and everthing works properly. Server.URLEncode will do all the work of
    > ensuring that the vpath value is correctly presented for URL use,
    > replacing all non-legal chars with URL entities.
    >
    > Dan
    >
    zz12, Jun 14, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave
    Replies:
    1
    Views:
    631
    John Timney \( MVP \)
    Feb 2, 2006
  2. Paul

    Response cutting off

    Paul, Apr 9, 2007, in forum: ASP .Net
    Replies:
    8
    Views:
    506
    George Ter-Saakov
    Apr 10, 2007
  3. Matt Haggard

    PIL cutting off letters

    Matt Haggard, Jun 15, 2007, in forum: Python
    Replies:
    4
    Views:
    301
  4. Joey Martin

    form field cutting off querystring

    Joey Martin, May 18, 2004, in forum: ASP General
    Replies:
    3
    Views:
    142
    Joey Martin
    May 18, 2004
  5. trans.  (T. Onoma)
    Replies:
    2
    Views:
    94
    trans. (T. Onoma)
    Oct 31, 2004
Loading...

Share This Page