If Page Is Default Then Include If Not Default Then
Solution 1:
Like many of your predecessors in ASP-classic-land, what you're wanting is conditional includes, and the problem you're bumping into is that classic ASP doesn't do conditional includes. (The reason why is that the #include
directive is handled long before any script on the page is parsed.)
There are various workarounds involving Execute
or other dangerous-in-the-wrong-hands commands; search for "asp conditional include" and you'll find more than you were bargaining for. However, in your case, it might be simpler to encase the slider display in a subroutine that you can call or not.
Slider.html:
<%
Sub DisplaySlider()
'code to display the slider (probably JavaScript, I'm guessing?)
%>
<script ...>
</script>
<%
End Sub
%>
Other pages:
<!-- #include virtual="/slider.html" -->
<%
scriptname = Request.ServerVariables("Script_Name")
If InStr(scriptname, "default.asp") > 0 Then
DisplaySlider
Else
Response.Write "<div class='spacer-top'></div>"
End If
%>
Solution 2:
Martha is bang on the nail.
To augment her answer I feel I should point out that system design comes into play, here. Try keeping your modules small and succinct, targeting their functionality to a particular aspect of your application's requirements. For example:
- one to deal with your data layer
- one to deal with more advanced form handling
- one to deal with blah
You get the idea.
Another idea is to include common functions in your global.asa
so they're available to all modules within your application instantly.
Post a Comment for "If Page Is Default Then Include If Not Default Then"