简体   繁体   中英

How to properly suppress a section of a Classic ASP page

I have a rather complex (>3k lines) Classic ASP Page that is supposed to suppress certain section based on the value of the CountryID. I've created boolean variables and set them to true if the CountryID of the Job is a particular value. The initial logic is as follows:

  blnUSJob = False
  blnCanadaJob = False
  blnAUJob = False
  blnNZJob = False
  nCountryID = 0

  If GetJobCountry(nJobAd_ID) = "CA" Then
     blnCanadaJob = True
     nCountryID = 2
 End If

I've created markup that renders if the blnCanadaJob evaluates to True:

<% 
if not blnCanadaJob then 
%>      
<tr>
<td width='30%' class='StandardLight' style="background-color:#dddddd" 
    valign='middle' align='right'>
<b>For replacement positions enter the following information for previous 
    incumbent</b>
<b>Name:</b><span class="Required">nbsp;*</span>&nbsp;<input type="text" 
    name="txtName" class="StdFieldName" value ="<%=strName %>" size="50" maxlength = 
    "50" /><br>
</td>
</tr>

Now, I need to ensure that this markup is suppressed for other CountryIDs. What would be the best way to accomplish this? Should I repeat the above markup with the evaluation statement for the specific country ID? Or, is there a more elegant way of handling this?

Thanks for your help and guidance.

If you have more options, a select statement would be best ( see here fi):

Select Case GetJobCountry(nJobAd_ID)
  Case "CA", "US":
    nCountryID = 2
    blnCanadaJob = True

  Case Else:
    blnCanadaJob = False

End Select

You can set option variables like blnCanadaJob there easily and it's more readable.

You can simplify this a little:

if GetJobCountry(nJobAd_ID) = "US" then

%>
<tr>
<td width='30%' class='StandardLight' style="background-color:#dddddd" 
    valign='middle' align='right'>
<b>For replacement positions enter the following information for previous 
    incumbent</b>
<b>Name:</b><span class="Required">nbsp;*</span>&nbsp;<input type="text" 
    name="txtName" class="StdFieldName" value ="<%=strName %>" size="50" maxlength = 
    "50" /><br>
</td>
</tr>
%>
end if

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM