简体   繁体   English

如何正确隐藏经典ASP页面的一部分

[英]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. 我有一个相当复杂的(> 3k行)经典ASP页面,该页面应根据CountryID的值来禁止显示某些部分。 I've created boolean variables and set them to true if the CountryID of the Job is a particular value. 如果作业的CountryID是特定值,我已经创建了布尔变量并将其设置为true。 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: 我创建了标记,该标记在blnCanadaJob评估为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. 现在,我需要确保为其他CountryID取消此标记。 What would be the best way to accomplish this? 做到这一点的最佳方法是什么? Should I repeat the above markup with the evaluation statement for the specific country ID? 我应该在针对特定国家/地区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): 如果您有更多选择,则选择语句将是最佳选择( 请参见此处 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. 您可以轻松地在其中设置选项变量,例如blnCanadaJob ,并且更具可读性。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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