Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert asp to cf

Status
Not open for further replies.

twcman

Programmer
Jun 28, 2001
284
US
OK you asp/cf people. I have converted an existing asp page to cf and am left with this one bit of code. Could someone please translate to cf for me?

<%
TeamNumber = Request(&quot;TeamNumber&quot;)
If IsEmpty(TeamNumber) Then
%>

<%
DocumentName = Request(&quot;DocumentName&quot;)
if DocumentName <> &quot;&quot; then
Response.Redirect(DocumentName)
end if
%>

1000 Thank you's. The only dumb questions are the ones that are never asked
 
SUPPOSING YOU ARE REQUESTING THE VARIABLES FROM A FORM:
<!--- ASP To ColdFusion --->
<cfoutput>
<cfset TeamNumber = &quot;#form.TeamNumber#&quot;>
<cfif len(TeamNumber) EQ 0>
<cfset DocumentName = &quot;#form.DocumentName#&quot;>
<cfif len(DocumentName) GT 0>
<cflocation url=&quot;#DocumentName#&quot;>
</cfif>
</cfif>
</cfoutput>
<!--- End: ASP To ColdFusion --->


ENHANCED:

<!--- ASP To ColdFusion --->
<cfoutput>
<cfif len(form.TeamNumber) EQ 0>
<cfif len(form.DocumentName) GT 0>
<cflocation url=&quot;#form.DocumentName#&quot;>
</cfif>
</cfif>
</cfoutput>
<!--- End: ASP To ColdFusion --->


Good Luck
 
I believe that the ASP IsEmpty also (nicely) checks for the existance of the variable and doesn't choke if it doesn't (unlike CF). So, to be safe (as safe as the ASP), you'd probably want a ColdFusion IsDefined() or <CFPARAM> in there somewhere as well... otherwise you might get as error where you didn't with ASP.

So something like:

Code:
<CFPARAM name=&quot;form.TeamNumber&quot; default=&quot;&quot;>
<CFPARAM name=&quot;form.DocumentName&quot; default=&quot;&quot;>
<cfoutput>
<cfif len(form.TeamNumber) EQ 0 AND len(form.DocumentName) GT 0>
   <cfoutput><cflocation url=&quot;#form.DocumentName#&quot;></cfoutput>
</cfif>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top