<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim objCtrl As Control
Dim strPage As String
strPage = Request.QueryString("p")
IF strPage = "page1" Then
objCtrl = LoadControl("~/MyUserControl4_1.ascx")
ElseIF strPage = "page2" Then
objCtrl = LoadControl("~/MyUserControl4_2.ascx")
Else
objCtrl = LoadControl("~/MyUserControl4_0.ascx")
End IF
Me.lblText.Controls.Add(objCtrl)
End Sub
</script>
<html>
<head>
<title>ThaiCreate.Com ASP.NET - Web User Control</title>
</head>
<body>
<form id="form1" runat="server">
<asp:HyperLink id="hplLink1" runat="server" NavigateUrl="?p=page1">Menu(1)</asp:HyperLink>
<asp:HyperLink id="hplLink2" runat="server" NavigateUrl="?p=page2">Menu(2)</asp:HyperLink>
<asp:Label id="lblText" runat="server"></asp:Label>
</form>
</body>
</html>
MyUserControl4_0.ascx
<script Language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Me.lblText.Text = "Welcome To www.ThaiCreate.Com"
End Sub
</script>
<table style="width: 550px" border="1">
<tr>
<td style="height: 73px; text-align: center">
<asp:Label ID="lblText" runat="server" Font-Size="X-Large"></asp:Label></td>
</tr>
</table>
MyUserControl4_1.ascx
<script Language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Me.lblText.Text = "Welcome To www.ThaiCreate.Com (1)"
End Sub
</script>
<table style="width: 550px" border="1">
<tr>
<td style="height: 73px; text-align: center">
<asp:Label ID="lblText" runat="server" Font-Size="X-Large"></asp:Label></td>
</tr>
</table>
MyUserControl4_2.ascx
<script Language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Me.lblText.Text = "Welcome To www.ThaiCreate.Com (2)"
End Sub
</script>
<table style="width: 550px" border="1">
<tr>
<td style="height: 73px; text-align: center">
<asp:Label ID="lblText" runat="server" Font-Size="X-Large"></asp:Label></td>
</tr>
</table>