Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll
<Asp.net blog>
<personal site>
[prev. Lesson]  User Controls
     [next Lesson]  UCs: Database List Boxes

User Controls Simple Example by Charles Carroll

This page demonstrates how to use a User Control to re-use some code.

Simple page:

   filename=/experiments/usercontrolbasics/reusebasics.aspx

<Test Script Below>


<%@ Register TagPrefix="LearnAsp" TagName="Header" Src="header.ascx" %>
<%@ Register TagPrefix="LearnAsp" TagName="Footer" Src="footer.ascx" %>
<html><head>
<title>Sample of Re-Using Code</title>
</head>
<body bgcolor="#FFFFFF">
<LearnAsp:Header runat="server"/>
Test Document
<LearnAsp:Footer runat="server"/>
</body></html>



The Header User Control:

filename=/experiments/usercontrolbasics/header.ascx


This is my header<hr>



The Footer User Control:

filename=/experiments/usercontrolbasics/footer.ascx


<hr>This is my footer



There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.