带空格的参数接收问题
页面1:<a href="e-cp1.asp?csort=RUBBER AND RUBBER PRODUCTS">RUBBER AND RUBBER PRODUCTS</a>
页面2: e-cp1.asp 接收到的参数csort内容为 RUBBER AND RUBBER PRODUCTS
但在分页的时候(参数两个page ,csort) 比如说第二页的时候csort 的值就变成 RUBBER
空格之后的内容就被截断了
这个问题怎么解决
问题点数:50、回复次数:8Top
1 楼asp_m(写个三层模式)回复于 2005-09-21 12:00:14 得分 1
关注一下:)Top
2 楼tigerwen01(小虎)回复于 2005-09-21 12:02:14 得分 40
使用Server.URLEncode(VariableName)来保证传递过去
变量的是按照 URL格式编码的Top
3 楼terry_yip(我只回答引起我思考的问题)回复于 2005-09-21 12:58:03 得分 2
你传过去时,把用replace函数把空格用下划线来代替,然后传到下一个页面时,先得到这个带下划线的参数,再用replace函数,把下划线替换成空格,
关于replace函数的用法,参见:
http://www.54uc.com/asppost13/web248603.htm
Top
4 楼shhu_lin(hupo)回复于 2005-09-21 13:34:18 得分 0
看看这样使用对不对
csort=Server.URLEncode(Request.querystring("csort"))
就不能查到具体的产品了Top
5 楼ivee(ivee)回复于 2005-09-21 13:39:20 得分 5
链接要写成:<a href="e-cp1.asp?csort=<%=Server.UrlEncode("RUBBER AND RUBBER PRODUCTS")%>">RUBBER AND RUBBER PRODUCTS</a>Top
6 楼shhu_lin(hupo)回复于 2005-09-21 13:39:42 得分 0
在第二个页面能收到 RUBBER AND RUBBER PRODUCTS
但在 使用分页的时候就会出现 只有RUBBER后面的就没有了
Top
7 楼cnguai(怪虎)回复于 2005-09-21 13:48:03 得分 2
把空格改成%20Top
8 楼shhu_lin(hupo)回复于 2005-09-21 14:02:26 得分 0
从页面1 接收到的 参数csort 值是RUBBER AND RUBBER PRODUCTS
在页面2 分页的时候 csort的值 就只有RUBBER 了
<%
Const MaxPerPage=14
dim totalPut
dim CurrentPage
dim TotalPages
dim j
dim sql
if Not isempty(request.QueryString("page")) then
currentPage=Cint(request.QueryString("page"))
else
currentPage=1
end if
dim csort
csort=Request.QueryString("csort")
Response.Write csort
set rs=Server.CreateObject("ADODB.Recordset")
sqlss="select * from [cp] where ep_sort like '%"&csort&"%'"
rs.open sqlss,ccon,1,1
if err.number<>0 then
response.write("<script>alert('Sorry ,The Product not found!');window.open('e-cp.htm','_self');</script>")
end if
if rs.eof And rs.bof then
response.write("<script>alert('Sorry ,The Product not found!');window.open('e-cp.htm','_self');</script>")
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"e-cp1.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"e-cp1.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"e-cp1.asp"
end if
end if
end if
sub showContent
dim i
i=0
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#88C4FF">
<tr bgcolor="#C8D2F0" class="p10">
<td width="23%" height="30"><div align="center" class="style1">Name</div></td>
<td width="29%" height="30"><div align="center" class="style1">Specification</div></td>
<td width="23%" height="30"><div align="center" class="style1">Packing</div></td>
<td width="12%" height="30"><div align="center" class="style1">Habitat</div></td>
<td width="13%" height="30"><div align="center" class="style1">Specify</div></td>
</tr>
<%
do while not rs.eof
%>
<tr class="p10">
<td height="25" bgcolor="#F0F3FB"><div align="center"><a onclick="return callpage(this.href)" href="e-cp01.asp?id=<%=rs("id")%>"> <%=left(rs("ep_name"),8)%></a></div></td>
<td height="25" bgcolor="#F0F3FB"><div align="center"> <%=left(rs("ep_maioshu"),20)%></div></td>
<td height="25" bgcolor="#F0F3FB"><div align="center"> <%=rs("p_baozhuang")%></div></td>
<td height="25" bgcolor="#F0F3FB"><div align="center"> <%=rs("ep_chandi")%></div></td>
<td height="25" bgcolor="#F0F3FB"><div align="center"><A onclick="return callpage(this.href)" href="e-cp01.asp?id=<%=rs("id")%>">Specify</a></div></td>
</tr>
<%
i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing
%>
</table>
<%
End Sub
Function showpage(totalnumber,maxperpage,filename)
Dim n
If totalnumber Mod maxperpage=0 Then
n= totalnumber \ maxperpage
Else
n= totalnumber \ maxperpage+1
End If
Response.Write "<form method=Post action="&filename&">"
Response.Write "<p align='center' class='contents'> "
If CurrentPage<2 Then
Response.Write "<font class='contents'>Home Previous</font> "
Else
Response.Write "<a href="&filename&"?page=1&csort="&csort&">Home</a> "
Response.Write "<a href="&filename&"?page="&CurrentPage-1&"&csort="&csort&">Previous</a> "
End If
If n-currentpage<1 Then
Response.Write "<font class='contents'>Next Tail</font>"
Else
Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&csort="&csort&">"
Response.Write "Next</a> <a href="&filename&"?page="&n&"&csort="&csort&">Tail</a>"
End If
Response.Write "<font class='contents'> Order:</font><font class='contents'>"&CurrentPage&"</font><font class='contents'>/"&n&"Page</font> "
Response.Write "<font class='contents'> Total"&totalnumber&"Product "
Response.Write "<font class='contents'>Jump:</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="¤tpage&">Page"
Response.Write " <input type='submit' class='contents' value='Jump' name='cndok' ></form>"
End Function
%>
Top




