This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 头疼,这两天突然一个asp的程序竟然不能取得参数了,一个叶面上的连接http://dellsrv/rnd/materials/SMAbbr.asp?pn=2&sorttype=,结果在smaddr.asp去读参数PN,竟然是空的,什么也没有。请教高手。连接:
<td class=right><A href="SMAbbr.asp?pn=2&sorttype=">2 TH RC & IC</a></td>
asp:
pn=trim(request("pn"))
if pn="" or len(pn)<>1 then
Response.Write ("a" & pn & "b")
Response.End
end if
-haihai(好了,大概是250);
2003-10-21
{215}
(#1425375@0)
-
2点建议:1, 如果知道从URL里取值, 建议用Request.QueryString, 仅用request时, submit 的form里的值会优先.
2. URL传递参数时, 变量名最好明确如"URL_PN"如果不愿意用其他参数名字. 但建议建立Naming convention帮助程序辨别变量范围.
-anno(烦人);
2003-10-21
{212}
(#1425386@0)
-
coz,,,it's working, just tried, move the response.write statement out of the if block,
-mustang(mustang);
2003-10-21
{81}
(#1425393@0)
-
response.write只是写了测试用的,没什么意义,现在一部分电脑工作正常,能得到参数,另外一部分不行,:(。准备用楼上兄弟的方法看看
-haihai(好了,大概是250);
2003-10-21
(#1425412@0)
-
just the if statement does not make sense to me,,, i guess u want to do the reverse way, and morerequest("var-name") works for .form/.querystring/.cookie,
if you don't want to confuse your system, try be more specific,
copy/paste the following code to your smabbr.asp file, you will
tell your problem yourself
Response.Write ".form" & Request.Form ("pn") & "<br>"
Response.Write ".querystring" & Request.QueryString ("pn") & "<br>"
Response.Write ".cookie" & Request.Cookies ("pn") & "<br>"
-mustang(mustang);
2003-10-21
{424}
(#1425492@0)
-
Request.Form("var"), Request.QueryString("var")应该没有区别, 常见的web server不区分Get还是Post, 除非你另外检查RequestMethod.
-miketany(MIKE老狼);
2003-10-21
(#1425528@0)
-
len(pn)<>1 ?你现在因为pn=2,所以len(pn)==1,当然response不会输出了仔细检查一下就行
用Request("pn")没什么不对,至少不用担心form从get变成post
-happyallday(happyallday);
2003-10-21
{76}
(#1425595@0)
-
request.form & cookie & querystring的结果都是nothing, :-(
-haihai(好了,大概是250);
2003-10-22
(#1426704@0)