Passing a string with spaces to another ASP page

Results 1 to 5 of 5

Thread: Passing a string with spaces to another ASP page

  1. #1
    Join Date
    Dec 1969
    Posts
    20

    Default Passing a string with spaces to another ASP page

    Hi All,<BR>I&#039m try to pass a value to another ASP but the value may contain spaces (it&#039s a named title). It works with strings without spaces fine but does not work when the string contains spaces. The sending file contains the following:<BR><BR>Response.write "&#060;A HREF=&#039coursedata.asp?prgList=" & oRs("PROGAREA") & "&#039>"<BR><BR><BR><BR>And the receiving file contains:<BR><BR>&#039Generate SQL statment<BR>CourseCode = Request.QueryString("prgList")<BR><BR>strSQL = "SELECT * FROM CourseInfo WHERE PROGAREA=&#039" & CourseCode & "&#039"<BR>&#039Create recordset object with SQL Statement<BR>Set oRs = oConn.Execute(strSQL)<BR><BR><BR><BR><BR>The result of the code for titles with space characters is :<BR><BR>HTTP Error 400<BR>400 Bad Request<BR>Due to malformed syntax, the request could not be understood by the server. The client should not repeat the request without modifications.<BR><BR>Would appreciate any help,<BR>Thanks!<BR>Tim

  2. #2
    Ian Stallings Guest

    Default RE: Passing a string with spaces to another ASP page

    You would have to URLencode it using:<BR>Server.URLEncode(oRs("PROGAREA")) before writing it<BR>in the href.<BR><BR>This should work.<BR><BR>Ian

  3. #3
    Jason Guest

    Default RE: Passing a string with spaces to another ASP page

    I have had the same problem. What I did to fix the problem is use the replace funtion (This is in VBscript). I would replace all the spaces with an underscore and send that to another page. In the other page I would again use the replace function and replace the underscore with a space. You can go to microsofts web site and search for VBscript to find a tutorial.<BR><BR>Hope this helps.

  4. #4
    Jason Guest

    Default RE: Passing a string with spaces to another ASP page

    I have had the same problem. What I did to fix the problem is use the replace funtion (This is in VBscript). I would replace all the spaces with an underscore and send that to another page. In the other page I would again use the replace function and replace the underscore with a space. You can go to microsofts web site and search for VBscript to find a tutorial.<BR><BR>Hope this helps.


  5. #5
    Join Date
    Dec 1969
    Posts
    20

    Default RE: Passing a string with spaces to another ASP page

    Thanks to both of you...<BR>I&#039ve found that it seems to work fine in Internet Explorer but does not work in Netscape and that the problem, I believe, lies in the SQL statement with the spaces.. <BR><BR>strSQL = "SELECT * FROM CourseInfo WHERE PROGAREA=&#039" & CourseCode & "&#039"<BR><BR>Will try both your ideas and see if they work...<BR>Thanks,<BR>Tim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •