[英]Using IF Then and Response.Redirect in ASP
So I have three pages. 所以我有三页。 The first page I define a link with a string 第一页我定义了一个带有字符串的链接
<a href="divProgLog.asp?div=Division 2">
The second page I grab the string and assign a variable 第二页我抓取字符串并分配一个变量
<% divrec = request.QueryString("div")%>
The third page processes everything. 第三页处理所有内容。 I would like for the process to be if the string is equaled to Division 2 the user will be redirected to another page. 我希望该过程是如果字符串等于Division 2,则该用户将被重定向到另一个页面。 I'm using the following code but its not working 我正在使用以下代码,但无法正常工作
divstring = "divisions.asp?div=" & divrec & "&Last_Name=" & Last_Name & "&First_Name=" &First_Name
divstring2 = "divisions2.asp?div=" & divrec & "&Last_Name=" & Last_Name & "&First_Name=" &First_Name
if divrec = Division 2 then
Response.Redirect divstring2
else
Response.Redirect divstring
end if
I didn't use VB.Net for a long time, but try this: 我已经很长时间没有使用VB.Net了,但是请尝试以下操作:
divstring = "divisions.asp?div=" & divrec & "&Last_Name=" & Last_Name & "&First_Name=" &First_Name
divstring2 = "divisions2.asp?div=" & divrec & "&Last_Name=" & Last_Name & "&First_Name=" &First_Name
If divrec = "Division 2" Then
Response.Redirect(divstring2)
Else
Response.Redirect(divstring)
End If
Your page shouldn't be compilable by the way. 顺便说一下,您的页面不应该被编译。
Do not forget to use an upper case for If
, Then
and End If
. 不要忘记对If
, Then
和End If
使用大写字母。
Also Division 2
is a string so you have to surround it with double-quotes. 另外, Division 2
是一个字符串,因此您必须用双引号将其引起来。
Response.Redirect
is a method so parameters are specified between parenthesis. Response.Redirect
是一种方法,因此可以在括号之间指定参数。
I think you should try taking the space out of Division 2 ID and rename it to Division2. 我认为您应该尝试从Division 2 ID中删除该空间并将其重命名为Division2。
ie <a href="divProgLog.asp?div=Division2">
即<a href="divProgLog.asp?div=Division2">
Then modify your code to be 然后将您的代码修改为
If divrec = "Division2" Then
Response.Redirect(divstring2)
Else
Response.Redirect(divstring)
End if
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.