Here''''s the entire HTML code that is sent back from the example VB method along with the supporting HTML code that we''''ll provide in the ASP file. All the HTML code not sent from the VB method is in bold text. The browser rendered code is displayed before the HTML source code.
The combined ASP file code and the HTML code that''''s returned from the VB code:
Although the VB method code will be covered in detail later in this article, we need to know what will be needed in order to design its method parameters. Again, we''''ll be getting values from three sources outside of the VB code itself; values sent as method parameters, a database table storing different HTML "presentation-style" values, and the database table that stores the titles and title''''s text.
<HTML><HEAD><TITLE>Note Example</TITLE></HEAD>
<BODY LINK="Navy">
<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="3"><TR>
<!-- === THE FOLLOWING HTML CODE WAS RETURNED BY THE VB CODE === -->
<!-- ///// LEFT HAND SIDE OF TABLE RECORD ///// -->
<TD WIDTH="74" NOWRAP VALIGN="top">
<FONT FACE="Verdana" SIZE="1" COLOR="GRAY">
<A HREF="NoteExample.asp?ID=1">Intro</A>
<BR>
<A HREF="NoteExample.asp?ID=2">Style Tables</A>
<BR>
<A HREF="NoteExample.asp?ID=3">GetRows()</A>
<BR>
Buffering<BR>
<A HREF="NoteExample.asp?ID=5">Transactions</A>
<BR>
</FONT>
</TD>
<!-- ///// RIGHT HAND SIDE OF TABLE RECORD ///// -->
<TD WIDTH="124" VALIGN="top" BGCOLOR="#EFEFEF">
<FONT FACE="Verdana" SIZE="1" COLOR="NAVY">
Using string buffering can optimize concatenation operations and avoid slowdowns
</FONT>
</TD>
<!-- ============================================= -->
</TR></TABLE>
</BODY>
</HTML>
It has already been mentioned that we''''ll be sending the NoteID value to the VB code via a method parameter. The NoteID value will be passed back to our ASP file via a query string when a user selects a title link. But there are also other nonpresentation values that will change frequently and can be provided to the VB code via method parameters.
Since the ASP developer using our VB method may want to use it in a number of different files, or rename the callback ASP file something other than NoteExample.asp, we''''ll provide a method parameter for changing the name of the ASP file. The VB method will use this file name parameter value to construct the HREF values of the <A> tags within the title list. We''''ll call this method parameter strURL.
Another frequently changed, and necessary, value is the database connection string. We''''ll use an Open DataBase Connectivity (ODBC) Data Source Name (DSN) name for our example, but it can also be set to a DSN-less connection string. This method parameter name will be strConnectionString. You''''ll need to set an ODBC DSN connection to the example database, NoteDb.mdb, and name it "NotesDSN" to use this article''''s default code. (How to establish a ODBC DSN connection is described later.)
Lastly, we need a way of picking which database table record is used for the HTML presentation-style values, although a set of local default VB variables will be provided as an alternative to using these database values. The intStyleID method parameter will be used for this. Since this value may be used more frequently than the previous two method parameters described above, we''''ll place it second in the method parameter list, right behind the lngNoteID method parameter.
Below is the completed VB method signature. Since the browser rendered TABLE sent back by the method displays text related to various note titles, we''''ll call the method ShowNotes().
The VB Method Signature Notice that the intStyleID, strURL, and strConnectionString parameter variables are set as "optional" and have default values that match the ASP file and DSN names used in this articles'''' example code. The method also returns a string that will contain our constructed HTML code, combined with the values generated from the database and method parameters.
Public Function ShowNotes(ByVal lngNoteID As Long, _
Optional ByVal intStyleID As Integer = 0, _
Optional ByVal strURL As String = "NoteExample.asp", _
Optional ByVal strDbConnectionString As String = "NotesDSN" ) As String
Below is the entire ASP file code that will call our VB method and create the HTML code displayed in the "What the Example Application Does" section. The specific details of calling a VB method with parameters were covered in the first article. The details of the VB project, class, and method used in this ASP code will be discussed later in this article.
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




