The ASP file we're going to generate is shown below - I will #include it just like any other file, then call the function ShowNews().utils/News.asp<%
function ShowNews ( )
{
Out('<table width="100%" border="0" align="center">' );
Out('<tr><td width="90%" nowrap valign="top">' );
Out('<table width="100%">');
Out('<tr><td>• <a href="http://aspwire.com/brief.asp?6275" target="CYAExternal">Amazing New ASP Template Pack</a></td></tr>');
Out('<tr><td>• <a href="http://aspwire.com/brief.asp?6274" target="CYAExternal">A/V Publisher</a></td></tr>');
Out('<tr><td>• <a href="http://aspwire.com/brief.asp?6273" target="CYAExternal">fXgraph Ver 4 Beta Animated Graphing Comp Released</a></td></tr>');
Out('<tr><td>• <a href="http://aspwire.com/brief.asp?6271" target="CYAExternal">CompareFilesX now has reporting built in</a></td></tr>');
Out('<tr><td>• <a href="http://aspwire.com/brief.asp?6272" target="CYAExternal">CodeCharge Studio ASP code generator Released</a></td></tr>');
Out('<tr><td>• <a href="http://aspwire.com/brief.asp?6298" target="CYAExternal">URLDecode Function</a></td></tr>');
Out('<tr><td>• <a href="http://aspwire.com/brief.asp?6297" target="CYAExternal">An Extensive Examination of the DataGrid Web Control: Part 5</a></td></tr>');
Out('<tr><td>• <a href="http://aspwire.com/brief.asp?6296" target="CYAExternal">Protecting Portions of your Web Site</a></td></tr>');
Out('<tr><td>• <a href="http://aspwire.com/brief.asp?6295" target="CYAExternal">Specifying Configuration Settings in Web.config</a></td></tr>');
Out('</table>');
Out('</td><td width="10%" nowrap valign="bottom">' );
Out('<a href="http://aspwire.com/" target="CYAExternal"><img src="images/Affiliates/ASPWire.gif" width="100" height="30" alt="News from ASPWire" border="0"></a><br><b>Powered by ASPWire</b><br><a href="GetNews.asp">Read how this is done</a>');
Out ( '</td></tr></table>' );
}
%> | Back in OnInitialUpdate, here's how I created the News.asp file:// open file to store formatted data into
TCHAR* sNewsFile = _T( "News.asp" );
CStdioFile cfASP ( sNewsFile, CFile::modeCreate | CFile::modeWrite );
// output the static part of the asp file - the function declaration,
// the ASPWire image and the heading
cfASP.WriteString ( _T("<%\nfunction ShowNews ( )\n{\n") );
cfASP.WriteString ( _T("\tOut('<a href=\"http://aspwire.com/\"><img src=\"images/ASPWireNews.gif\" alt=\"News from ASPWire\" border=0></a>');\n") );
cfASP.WriteString ( _T("\tOut(' (<a href=\"GetNews.asp\">Read how this is done</a>)<p>');\n") );
cfASP.WriteString ( _T("\tOut('<table width=\"100%\">');\n") );
cfRaw.SeekToBegin ();
CString sLine;
bool bNewRow = true;
for (int i=0; ; i++)
{
if ( FALSE == cfRaw.ReadString ( sLine ) )
break;
switch ( i % 4 )
{
case 0: // URL
cfASP.WriteString ( _T("\tOut('") );
if ( bNewRow )
cfASP.WriteString ( _T ( "<tr>" ) );
bNewRow = !bNewRow;
cfASP.WriteString ( _T("<td>• <a href=\"") );
cfASP.WriteString ( sLine );
cfASP.WriteString ( _T("\" target=\"CYAExternal\">") );
break;
case 3: // title
sLine.Replace ( "'", "\\'" );
cfASP.WriteString ( sLine );
cfASP.WriteString ( _T("</a></td>") );
if ( bNewRow )
cfASP.WriteString ( _T ( "</tr>" ) );
cfASP.WriteString ( _T("');\n") );
break;
}
}
cfASP.WriteString ( _T("\tOut('</table>');\n") );
cfASP.WriteString ( _T("}\n%>") );
// close files
cfRaw.Close ();
cfASP.Close ();
| As Emeril would say: BAM! Now I have our News.asp file on our local machine, so the last step is to upload it to our server.Part 4: Uploading via FTP...  |