Part V: Creating the Web Pages

Step 1

Start Visual InterDev. Create a new web project by choosing New from the File menu. When the New dialog box appears, click the Projects tab, and then choose the Web Project wizard. Locate your new project below the \MTS directory you created earlier, and then give your project the name NorthWind. Click OK.

Step 2

The Web Project wizard will ask you for the name of the Web server on which the new project will be created. If this text box contains an entry, you can accept it; if the box is empty, type the name of the machine that is running Internet Information Server. Click Next. If you don't know the correct name of your Web server, look up the Identification information by using the Network applet in the Control Panel.

The Web Project wizard will contact the selected Web server and present you with the step 2 dialog box. Choose the option Create A New Web. Make sure the name of the web is NorthWind. Check the option to enable full-text searching of the site, and click Finish. The Web Project wizard will create your new web and open the project.

Step 3

This project will be built in a set of browser frames. Add a new HTML page for the frames by choosing New from the File menu. In the New dialog box, add a new HTML page and name the page DEFAULT.HTM. Click OK.

Define the frame set for the application by altering the Web page to appear as follows:

<HTML> <HEAD> <TITLE>Transaction Server</TITLE> </HEAD> <BODY> <FRAMESET COLS="27%,73%">     <FRAME SRC="categories.asp" NAME="LIST" SCROLLING="No">     <FRAME SRC="products.asp" NAME="MAIN" SCROLLING="No"> </FRAMESET> </BODY> </HTML> 

Save the page.

Step 4

Add a new ASP page to the project by choosing New from the File menu. In the New dialog box, select to add a new ASP page and name the page CATEGORIES.ASP. Click OK.

This page will present a list of product categories to the user, who can then view the products by clicking hyperlinks. Add the following code to the BODY section of the page to create the categories from the NorthWind data source:

<% ` Variables Dim objQuery ` Create the business object Set objQuery = Server.CreateObject("MTSObject.Query") ` Run the query Dim strReturn strReturn = objQuery.GetCategories ` Fill the list box Dim intStart Dim intCurrent intStart = 1 intCurrent = 1 ` Parse the returned string Do While intCurrent < Len(strReturn)     intCurrent = InStr(intStart, strReturn, "|")     If intCurrent = 0 Then Exit Do %> <FONT FACE="Verdana" SIZE=4> <A TARGET="MAIN"  HREF="products.asp?Product=<%=Server.URLEncode(Mid(strReturn, intStart,                                             intCurrent - intStart))%>">     <%=Mid(strReturn, intStart, intCurrent - intStart)%> </A> </FONT> <%     intStart = intCurrent + 1 Loop %> 

Step 5

Add a new ASP page to the project by choosing New from the File menu. In the New dialog box, select to add a new ASP page and name the page PRODUCTS.ASP. Click OK.

This page will build a table of all products from the database in the selected category. Add the following code to the BODY section to create the HTML table:

<% ' Create business object Dim blnReturn Dim objProducts Set objProducts = Server.CreateObject("MTSObject.Query") ' Run query Dim varReturn blnReturn = _     objProducts.GetProducts(Request.QueryString("product"), varReturn) %> <IMG SRC="banner.gif"><P> <!-- Begin table definition --> <TABLE BORDER WIDTH=100%>     <TR>     <TD>     Product     </TD>     <TD>     Company     </TD>     <TD>     Price     </TD>     </TR> <% ' Fill the grid Dim i For i = 0 To UBound(varReturn, 2) %>     <TR>     <TD>     <%=varReturn(0, i)%>     </TD>     <TD>     <%=varReturn(1, i)%>     </TD>     <TD>     <%=varReturn(2, i)%>     </TD>     </TR> <% Next %> </TABLE> 

Step 6

Save the project, and view DEFAULT.HTM in Internet Explorer. The result should look like the page in Figure 10-4. You will access Visual Basic business objects in MTS to perform the queries.

Figure 10-4. The completed exercise.



Programming Active Server Pages
Programming Active Server Pages (Microsoft Programming Series)
ISBN: 1572317000
EAN: 2147483647
Year: 1996
Pages: 84

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net