Looping code that i cant seem to work out!

L

Luke - eat.lemons

Sorry for the post in this NG but im short on time to get this working
and i haven't seem to of got a response anywhere else.

Im pretty new to asp so all light on this question would be great.

Basically i need to test to see what value is set (where to retrieve the
data from) so ive done it like this:

If Request.Querystring("id") = "" then
TidF=Request.Form("TidF")
Else
TidF=Request.Querystring("id")
End If

The data Request.Form("TidF") comes from a form if submit is pressed.

The data Request.Querystring("id") comes from the url being .asp?id=number

However it seems to keep looping round even though i have ended the if
statement and set the var.

all help would be great thanks.
 
C

Chris Fulstow

The "If-Else" statement won't cause your code to loop because it's just
a conditional statement. Maybe the behaviour is caused by a different
part of your code? Do you have any "For", "While", "Do...While" or
"For Each" statements?
 
L

Luke - eat.lemons

Chris said:
The "If-Else" statement won't cause your code to loop because it's just
a conditional statement. Maybe the behaviour is caused by a different
part of your code? Do you have any "For", "While", "Do...While" or
"For Each" statements?
Thanks for the reply, yes it does contain a loop but the code only seems
to keep looping round since ive added the If statement to get the data.

Here is my code.

http://rafb.net/paste/results/qXOfJn50.html

thanks agian!
 
S

sloan

Maybe not the complete answer, but here is a helper.


If Request.Querystring("id") = "" then
TidF=Request.Form("TidF")
Else
TidF=Request.Querystring("id")
End If



if ( Request.Querystring("id") is nothing) then
'' "id" not present, check for TidF
if not (Request.Form("TidF") is nothing) then
TidF=Request.Form("TidF")
else
throw new ArgumentException("Form( TidF ) expected.")
end if

else

if Request.Querystring("id").Length <= 0 then
throw new ArgumentException("Querystring( id) expected.")
end if
TidF=Request.Querystring("id")

end if


Don't check for empty strings as the "exists or not exists". Check for the
object existing or not (null in C# / Nothing in VB.net)

...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top