User controls are somewhat outdated already with the introduction of partial classes in ASP.NET 2.0 but I still find them useful. I think of them similar to the include pages in classic ASP. This is a simple example of how to get the text value from a user control on the parent page.
<%@ Page Language="VB" %>
<%@ Register Src="header.ascx" TagName="header" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load(ByVal Src As Object, ByVal E As EventArgs)
Dim CompanyName As TextBox = CType(Page.FindControl("Header1$txtCompanyName"), TextBox)
lblCompanyName.Text = CompanyName.Text
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<!--This is my user control page header-->
<uc1:header id="Header1" runat="server"></uc1:header>
<br />
<br />
<asp:Label ID="lblCompanyName" runat="server" Text="Label" />
<asp:TextBox ID="TextBox1" runat="server" />
</div>
</form>
</body>
</html>
This is an example of how to set the text value from inside the user control on the parent page.
<%@ Control Language="VB" ClassName="header" EnableViewState="false" %>
<script runat="server">
Private Sub Page_Load(ByVal Src As Object, ByVal E As EventArgs)
If Not Page.IsPostBack Then
Dim TextBox1 As Textbox =CType(Me.Parent.FindControl("TextBox1"),TextBox)
TextBox1.Text = "Eat your veggies"
End If
End Sub
</script>
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td>Company: <asp:Textbox ID="txtCompanyName" runat="server" CssClass="textbox" Text="Company Name" ToolTip="Enter a company name" />
<asp:Button ID="btnCompanySearch" runat="server" Text="go" CssClass="buttons" OnClick="QuickSearch_Companies_Click" /></td>
</tr>
</table>