<%@ Page Language="VB" %>
<%@ Reference Control="~/Listing26-8.ascx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim myForm As Control = Page.FindControl("form1")
        Dim c1 As Control = LoadControl("Listing26-8.ascx")
        myForm.Controls.Add(c1)
        
        If (c1.GetType() Is GetType(WebUserControl8)) Then
            'This control is not participating in OutputCache
            CType(c1, WebUserControl8).ID = "myWebUserControl1"
            CType(c1, WebUserControl8).Text = "My users controls text"
            
        ElseIf (c1.GetType() Is GetType(PartialCachingControl) And _
            ((CType(c1, PartialCachingControl)).CachedControl IsNot Nothing)) Then

            'The control is participating in output cache, but has expired
            Dim myWebUserControl As WebUserControl8 = _
                CType((CType(c1, PartialCachingControl).CachedControl),  _
                WebUserControl8)

            myWebUserControl.ID = "myWebUserControl1"
            myWebUserControl.Text = "My users controls text"
        End If

    End Sub
</script>


<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
</body>
</html>
