Using Server Side Include Files
page 2 of 4
by Steven Smith
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 27996/ 71

Sample Formatting Include File

My format include file:

   <!-- #include virtual="/ads/adshowaspa.asp"-->
   <!-- #include virtual="/stevesmith/include/AmazonLink.asp"-->
   <!-- #include virtual="/stevesmith/include/TitleCase.asp"-->
   <%
   
   'Preserved for old interface
   Sub ArticleHeader(title,javascript,css)
    Call ArticleHeader2(title,javascript,css,"")
   End Sub
10   
11   Sub ArticleHeader2(title,javascript,css,article_id)
12    Dim path
13    Dim index
14    Dim vpath
15    Dim querystring
16   %>

17   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
18   "http://www.w3.org/TR/REC-html40/loose.dtd">
19   <html>
20   <head>
21   <!--#INCLUDE VIRTUAL="stevesmith/metainc.asp"-->
22   <title><%=title%></title>
23   <link type="text/css" rel="stylesheet" href="http://www.aspalliance.com/stevesmith/include/ss.css" /></head>
24   <script type="text/javascript">
25   <!--
26   <%=javascript%>
27   
28   function openEmailWin(){
29    winTech=window.open('http://www.aspalliance.com/stevesmith/email.asp','Email','height=350,width=500,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1, scrollbar=1')
30   }
31   // -->
32   </script>
33   <% If css <> "" Then %>
34   <style type="text/css">
35   <!--
36   <%=css%>
37   -->
38   </style>
39   <% End If %>
40   <body topmargin="0" leftmargin="0"
41    marginwidth="0" marginheight="0" link="#0000ff" alink="#0000ff" vlink="#0000ff">
42   <%
43   If LCase(Request.Querystring("print_view")) <> "true" Then
44   %>

45   <table width="100%" cellpadding="4" cellpadding="0">
46   <TBODY>
47   <TR bgColor="#CC0000">
48    <TD height="50" width="80%" valign="absmiddle">
49    <table width="100%">
50    <tr>
51    <td align="center" width="145">
52    <a href=""><img
53    src="/libraryaspa/logocounter.asp?article_id=<%=article_id%>"
54    border="0" height="57" width="142" alt="ASPAlliance.com: The #1 ASP.NET Community"></a><br/>
55    <b>The ASPSmith</b>
56    </td>
57    <td align="center">
58    <% Call AdShowAspa() %>
59    </td>
60    </tr>
61    </table>
62    </TD>
63    <TD align="right" height="50" width="200">
64    <TABLE>
65    <TBODY>
66    <TR>
67    <TD class="small">
68    <FORM action="/search/default.asp" method="post" id="searchform"
69    name="searchform">
70    Search<BR>
71    <INPUT size="18" name="keyword">
72    </FORM>
73    </TD>
74    </TR>
75    </TBODY>
76    </TABLE>
77    </TD>
78   </TR>
79   </TBODY>
80   </TABLE>
81   <table width="100%" cellpadding="4" cellpadding="0">
82   <TBODY>
83    <TR bgColor="#000000">
84    <TD height="20" width="80%">
85    <span class="small">
86    <%
87    path = LCase(Request.Servervariables("path_translated"))
88    If InStr(1, path, "d:\domains\aspalliance.com\") Then
89    path = Replace(path, "d:\domains\aspalliance.com\", "")
90    vpath = "/"
91    %>

92    <A href="<%=vpath%>">ASPAlliance.com</A> |
93    <%
94    End If
95    If Left(path, 11) = "stevesmith\" Then
96    path = Replace(path, "stevesmith\", "")
97    vpath = vpath & "stevesmith/"
98   
99    dim stevehome
100    stevehome = vpath & "olddefault.asp"
101    %>

102    <a href="<%=stevehome%>">The ASPSmith Home</a> |
103    <%
104    End If
105    index = Instr(1, path, "\")
106    While index > 0
107    vpath = vpath & Left(path, index - 1) & "/"
108    Response.Write "<a href=""" & vpath & """>"
109    Response.Write TitleCase(Left(path, index - 1)) & "</a> | "
110    path = Right(path, len(path)-index)
111    index = Instr(1, path, "\")
112    Wend
113    %>

114    <%=title%>
115    </span>
116    </TD>
117    <TD align="right" height="20" width="200">
118    <div class="small">
119   <%
120    If Request.ServerVariables("QUERY_STRING") = "" Then
121    querystring = "?print_view=true"
122    Else
123    querystring = "?" & Request.ServerVariables("QUERY_STRING") & "&print_view=true"
124    End If
125   %>

126    <a href="<%=Request.ServerVariables("URL") & querystring %>"
127    target="_blank">Print View</a>
128    |
129    <a HREF="javascript:openEmailWin();"
130    onMouseOver="status='Feedback.'; return true;"
131    onMouseOut="status=''; return true;"
132    title="Feedback.">
133    Feedback
134    </a>
135    |
136    <a href="http://dotnetweblogs.com/ssmith/" target="weblog">My Blog</a>
137    </div>
138    </TD>
139    </TR>
140   </TBODY>
141   </TABLE>
142   <table width="100%" cellpadding="4" cellpadding="0" bgcolor="#FFFFFF">
143   <tr>
144    <td width="80%" align="left" valign="top">
145    <div class="articletitle"><%=title%></div><br />
146    <% if LCase(title) <> "table of contents" then %>
147    <div class="authorblock">By Steven Smith</div><br />
148    <% end if %>
149   <%
150    Else
151    'Print View
152   %>

153   <table width="600" bgcolor="#FFFFFF">
154    <tr>
155    <td align="center"><h2>The ASPSmith Articles, ASPAlliance.com</h2></td>
156    </tr>
157    <% if Len(title) > 0 then %>
158    <tr>
159    <td align="center"><div class="articletitle"><%=title%></div><br/>
160    <% if LCase(title) <> "table of contents" then %>
161    <div class="authorblock">By Steven Smith</div>
162    <% end if %>
163    </td>
164    </tr>
165    <% end if %>
166    <tr>
167    <td align="center">
168    <b>http://www.aspalliance.com<%=Request.ServerVariables("URL")%></b>
169    </td>
170    </tr>
171    <tr>
172    <td>
173   <%
174    End If
175   End Sub
176   %>

177   
178   <%
179   Sub ArticleFooter()
180    Dim filepath ' This file's path
181    Dim objFSO
182    Dim objFile ' An instance of the file object
183    Dim modify_date
184    Dim create_date
185   
186    filepath = Request.ServerVariables("PATH_TRANSLATED")
187    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
188    Set objFile = objFSO.GetFile(filepath)
189    modify_date = objFile.DateLastModified
190    create_date = objFile.DateCreated
191   
192    If LCase(Request.QueryString("print_view")) <> "true" Then
193   %>

194    </td>
195    <td align="right" valign="top" width="200">
196    <iframe src="http://ads.aspalliance.com/displayad.aspx?m=1&amp;t=6&amp;s=ROOT&amp;page=1" target=_parent" height="125" width="125"
197    marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"><script language="javascript"
198    src="http://ads.aspalliance.com/displayad.aspx?t=6&amp;m=1&amp;target=_parent&amp;js=1&amp;s=ROOT&amp;page=1"></script></iframe>
199    <br/><br/>
200    <% Call AdShowSmall() %>
201    <br /><br/>
202   <%
203    Call AmazonLink ("0672325241", _
204    "ASP.NET Developer's Cookbook, By Steven Smith, Rob Howard, ASPAlliance.com", _
205    "", _
206    true, "center")
207   %>

208    <br /><br/>
209   <%
210    Call AmazonLink ("0789725622", _
211    "ASP.NET By Example, By Steven Smith", _
212    "", _
213    true, "center")
214   %>

215    <br />
216    <br />
217    <% Call AdShowSmall() %>
218    <br/>
219    <br/>
220    <iframe src="http://ads.aspalliance.com/displayad.aspx?m=1&amp;t=5&amp;s=ROOT&amp;page=1" target=_parent" height="125" width="125"
221    marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"><script language="javascript"
222    src="http://ads.aspalliance.com/displayad.aspx?t=5&amp;m=1&amp;target=_parent&amp;js=1&amp;s=ROOT&amp;page=1"></script></iframe>
223    </td>
224   </tr>
225   </table>
226   <table width="100%" cellpadding="0" cellspacing="0">
227    <tr>
228    <td colspan="2" width="100%" align="center">
229    <hr color="red" width="90%" align="center" />
230    </td>
231    </tr>
232    <tr>
233    <td align="left" valign="top" width="30%">
234    <div class="authorblock">
235    <a HREF="javascript:openEmailWin();"
236    onMouseOver="status='Send email to Steve.'; return true;"
237    onMouseOut="status=''; return true;"
238    title="Send email to Steve."
239    >Steven Smith, MCSE + Internet (4.0)</a><br />
240    <b>Last Modified:</b> <%=modify_date%><br />
241    <b>History:</b> <%=create_date%>
242    </div>
243    <img src="/stevesmith/images/clear.gif" height="1" width="300" alt="">
244    </td>
245    <td align="center" valign="top" width="70%">
246    <% 'Call AdShowAspa %>
247   <%
248   End If 'non-print-view
249   %>

250    </td>
251    </tr>
252   </table>
253   </body>
254   </html>
255   <%
256   End Sub
257   %>


View Entire Article

User Comments

Title: f   
Name: f
Date: 2012-09-16 8:44:59 PM
Comment:
ff
Title: Trainer   
Name: Prajakta
Date: 2009-03-13 1:29:47 AM
Comment:
What is the disadvantage of include files over user controls?
Title: GUD   
Name: Raj
Date: 2005-12-12 4:54:20 AM
Comment:
ya very nice ya

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-18 11:47:21 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search