here are the three files used in this program
main3.aspx
<%@ Page Language="
VB" Debug="True" %>
<%@ Register TagPrefix="WroxUC" TagName="FeaturedBooks" Src="featuredbooks.ascx" %>
<%@ Register TagPrefix="WroxUC" TagName="Header" Src="header_CB.ascx" %>
<script runat="server">
' Insert page code here
'
</script>
<html>
<head>
<title>User Control Examples</title>
<link href="style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<form method="post" runat="server">
<WroxUC:Header id="MyHeader" runat="server"></WroxUC:Header>
<br />
<table>
<tbody>
<tr>
<td valign="top" width="70%">
This is the Wrox shop, where you can find out more about Wrox Books. The links take
you to a page on the wrox site where you can find out more details about each title.
</td>
<td width="30%">
<WroxUC:FeaturedBooks id="MyFeaturedBooks" runat="server"></WroxUC:FeaturedBooks>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
header_CB.
vb
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Collections
Public Class HeaderClass : Inherits UserControl
Private Languages As New Hashtable()
Private LanguageList As DropDownList
Private WelcomeMessage As Label
Public Sub Page_Load()
Languages.Add("English", "Hello, and welcome to the shop")
Languages.Add("French", "Bonjour, et bienvenue au magasin")
Languages.Add("Spanish", "Buenas Dias, e bienvenido a la tienda")
Languages.Add("German", "Guten Tag, und wilkommen ins geschaeft")
If Not Page.IsPostBack Then
LanguageList.DataSource = Languages.Keys
Page.DataBind()
End If
End Sub
Public Sub DropList_Changed(Sender As Object, E As EventArgs)
WelcomeMessage.Text = Languages(LanguageList.SelectedItem.Text)
End Sub
End Class
header_CB.ascx
<%@ Control Inherits="HeaderClass" Src="header_CB.
vb" Language="
VB" %>
<script runat="server">
' Insert page code here
'
</script>
<table style="BACKGROUND-COLOR: #cc0033" cellspacing="0" width="100%" cellpading="10">
<tbody>
<tr>
<td width="10%">
<img src="logo.gif" align="left" />
</td>
<td width="60%">
<asp:Label id="WelcomeMessage" runat="server"> Welcome
to the Wrox Shop! </asp:Label></td>
<td widt="30%">
Select your Language:<br />
<asp:DropDownList id="LanguageList" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropList_Changed"></asp:DropDownList>
</td>
</tr>
</tbody>
</table>
Mahir Ali Ahmed