Ver Mensaje Individual
  #11 (permalink)  
Antiguo 19/02/2006, 14:35
tammander
 
Fecha de Ingreso: enero-2006
Ubicación: Torroles (Costa der Só)
Mensajes: 1.017
Antigüedad: 19 años, 4 meses
Puntos: 7
¿Porque no usas el Server.URLEncode(cadena)?

Código:
<a href="buscar.asp?a=<% Server.URLEncode(response.write(rs.Fields("nombre1"))) %>">response.write(rs.Fields("nombre1"))</a>
<a href="buscar.asp?a=<% Server.URLEncode(response.write(rs.Fields("nombre1"))) %>"><%response.write(rs("nombre1"))%></a>
Esto te codifica segun las reglas de URL los espacios en blanco y algunos caracteres. Luego, en la otra página lo decodificas con esta funcion:

Código:
Function URLDecode(ByVal What)
  Dim Pos, pPos

  ' + --> ' '
  What = Replace(What, "+", " ")

  on error resume Next
  Dim Stream
  Set Stream = CreateObject("ADODB.Stream")
  If err = 0 Then 'URLDecode using ADODB.Stream, If possible
    on error goto 0
    Stream.Type = 2 'String
    Stream.Open

    ' %XX
    Pos = InStr(1, What, "%")
    pPos = 1
    Do While Pos > 0
      Stream.WriteText Mid(What, pPos, Pos - pPos) + _
        Chr(CLng("&H" & Mid(What, Pos + 1, 2)))
      pPos = Pos + 3
      Pos = InStr(pPos, What, "%")
    Loop
    Stream.WriteText Mid(What, pPos)

    'Read the text stream
    Stream.Position = 0
    URLDecode = Stream.ReadText

    'Free resources
    Stream.Close
  Else 'URL decode using string concentation
    on error goto 0
    'UfUf, this is a little slow method. 
    'Do Not use it For data length over 100k
    Pos = InStr(1, What, "%")
    Do While Pos>0 
      What = Left(What, Pos-1) + _
        Chr(Clng("&H" & Mid(What, Pos+1, 2))) + _
        Mid(What, Pos+3)
      Pos = InStr(Pos+1, What, "%")
    Loop
    URLDecode = What
  End If
End Function


Un saludo