1 创建用户控件
2 在母版页中注册用户控件
3 使用
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Store.master.cs" Inherits="SportsStore.Pages.Store" %> <%@ Register TagPrefix="SS" TagName="CatLinks" Src="~/Controls/CategoryList.ascx" %>
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SportsStore</title>
<link rel="stylesheet" href="../Content/Style.css" />
</head>
<body>
<form id="form1" runat="server">
<div id="header">
<div class="title">SPORTS STORE</div>
</div>
<div id="categories">
<SS:CatLinks runat="server" />
</div>
<div>
<asp:ContentPlaceHolder ID="bodyContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>