1 asp.net 中如何把用户控件应用于母版页

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>
原文地址:https://www.cnblogs.com/mibing/p/7435688.html