select case not working

M

mark.irwin

Hello all,

Have an issue where a redirect pushes data to a page with a select case
which then redirects to another page. Problem is the redirect isnt
working in 1 case. Code below:

strURL = ""

if i = 1 then
strURL = "redirect.aspx?page=APIQ&parcel=" & strParcel &
"&year=" & lbYear.text
elseif i > 1 then
strURL = "redirect.aspx?page=dockm&docket=" & tbSubDocket.text &
"&page=" & tbSubPage.text <====== PROBLEM STARTS HERE
end if

if strURL <> "" then
response.redirect(strURL)
end if


redirect.aspx code here:

select case request.QueryString("page")

case "stridx"
session("sname")= request.querystring("sname")

response.Redirect("stridx.aspx")

case "APIQ"
session("parcel") = request.QueryString("parcel")
session("year") = request.QueryString("year")

response.Redirect("APIQ.aspx")
case "pdssub"
session("map") = request.QueryString("rmap")
session("plat") = request.QueryString("rplat")

response.Redirect("pdssub.aspx")
case "dockm"
session("docket")= request.QueryString("docket")
session("page") = request.QueryString("page")

response.Redirect("asrdockm.aspx")
case else
response.Write("WHAT THE CRAP!!?!?!??!")

end select

the case statement i am having problems with is the dockm statement
code skips over it and goes to the else statement
all the other case statements work great

if i substitue dockm for APIQ in the URL string i get the same behavior

this works:
strURL = "redirect.aspx?page=APIQ&parcel=" & strParcel &
"&year=" & lbYear.text

this doesnt:
strURL = "redirect.aspx?page=dockm&docket=" & tbSubDocket.text &
"&page=" & tbSubPage.text

and modifying to this doesnt work either:
strURL = "redirect.aspx?page=APIQ&docket=" & tbSubDocket.text &
"&page=" & tbSubPage.text
(just changed page value to APIQ)

goes straight to else statement

Can anyone help with this?

Thanks in advance
 
B

Bruce Barker

you have a lot of bugs:

1) case sensitive compares
2) failure to urlen encode data

strURL = ""

if i = 1 then
strURL = string.Format("redirect.aspx?page=APIQ&parcel={0}&year={1}",
HttpUtility.UrlEncode(strParcel),
HttpUtility.UrlEncode(lbYear.text))
elseif i > 1 then
strURL = string.Format("redirect.aspx?page=dockm&docket={0}&page={1}",
HttpUtility.UrlEncode(tbSubDocket.text),
HttpUtility.UrlEncode(tbSubPage.text))
end if
if strURL <> "" then
response.redirect(strURL)
end if

redirect.aspx code here:

select case request.QueryString("page").ToLower()
case "stridx"
session("sname")= request.querystring("sname")
response.Redirect("stridx.aspx")
case "apiq"
session("parcel") = request.QueryString("parcel")
session("year") = request.QueryString("year")
response.Redirect("APIQ.aspx")
case "pdssub"
session("map") = request.QueryString("rmap")
session("plat") = request.QueryString("rplat")
response.Redirect("pdssub.aspx")
case "dockm"
session("docket")= request.QueryString("docket")
session("page") = request.QueryString("page")
response.Redirect("asrdockm.aspx")
case else
response.Write("WHAT THE CRAP!!?!?!??!")
end select
 
G

Guest

Hi,
it fails because you are using two variables of the same name "page" in the
querystring which creates an array with two values: QueryString("page")(0)
and QueryString("page")(1).
Rename the other "page" (this -> page=" & tbSubPage.text) to something else
and it will work.
Cheers
 
M

mark.irwin

LOL thanks.... I just noticed that when I got in this morning!!

rookie mistake.

thanks for the help
 
Top