Partager via


Visual Basic Concepts

Step Ten: Populate the Detail Page

The final step is to populate the detail.htm template with the appropriate data for display. In Step Eight you created a template .htm file that contained several markers, each beginning with a wc@ string. You will now add code to replace each of these markers with data from a record from the rs2 recordset.

You write the code for this replacement process in the Detail webitem’s ProcessTag event. The ProcessTag event is automatically fired whenever the WriteTemplate method is used for a template that contains replacement markers. In this case, the UserEvent procedure calls the Detail.WriteTemplate method, which causes processing to be passed to the Detail_ProcessTag event procedure.

To populate the Detail page

  • Update the Detail template’s ProcessTag event procedure (Detail_ProcessTag) to look like this:

    Private Sub Detail_ProcessTag(ByVal TagName As String, _
        TagContents As String, SendTags As Boolean)
            If TagName = "wc@Name" Then
                TagContents = rs2("FirstName") & " " & rs2("LastName")
            ElseIf TagName = "wc@Company" Then
                TagContents = rs2("CompanyName")
            ElseIf TagName = "wc@Title" Then
                TagContents = rs2("Title")
            ElseIf TagName = "wc@Email" Then
                TagContents = rs2("EmailName")
            ElseIf TagName = "wc@Refer" Then
                TagContents = rs2("ReferredBy")
            ElseIf TagName = "wc@Phone" Then
                TagContents = rs2("WorkPhone")
            ElseIf TagName = "wc@Notes" Then
                TagContents = rs2("Notes")
            End If
    End Sub