Thursday, March 22, 2012

Looping code that i cant seem to work out!

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.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?

--
Chris Fulstow
MCP, MCTS
http://chrisfulstow.blogspot.com/
Luke - eat.lemons@.gmail.com wrote:

Quote:

Originally Posted by

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.


Chris Fulstow wrote:

Quote:

Originally Posted by

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?
>
--
Chris Fulstow
MCP, MCTS
http://chrisfulstow.blogspot.com/
>
Luke - eat.lemons@.gmail.com wrote:

Quote:

Originally Posted by

>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.


>


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!
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)

...

<eat.lemons@.gmail.comwrote in message
news:vNqdnY17to414qHYRVnyhA@.eclipse.net.uk...

Quote:

Originally Posted by

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.
>

0 comments:

Post a Comment