65.9K
CodeProject 正在变化。 阅读更多。
Home

ascx

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0投票)

2013 年 10 月 11 日

CPOL
viewsIcon

8485

当 ASP.Net 服务器控件的标准工具包无法提供所需的功能时,可以使用或构建 Web 用户控件。Web 用户

当 ASP.Net 服务器控件的标准工具包无法提供所需的功能时,可以使用或构建 Web 用户控件。Web 用户控件的构建方式与 Web 窗体 (.aspx) 相同,但它不能包含 <HTML>、<BODY> 和 <FORM> html 元素,因为这些元素将由托管该控件的 Web 窗体持有。

ASP.NET 中的 Web 用户控件以 .ascx 扩展名结尾。它们可以通过在页面上使用 Register 标签或在 web.config 文件中注册,在 ASP.NET 页面中使用。用户控件在重用逻辑时非常有用。自定义服务器控件用于代码将在 DLL 中重用的情况。

示例

<%@ Register src="~/Controls/LatestPosts.ascx" TagName="LatestPosts" TagPrefix="pageElements" %>
<pageElements:LatestPosts ID="latest1" runat="server"></pageElements:LatestPosts>

链接

© . All rights reserved.