当您将 Web 用户控件拖到设计图面上时,它将自动分配 tagprefix = uc1。
有谁知道如何更改所有网络用户控件的默认标签前缀 您将其拖到网络表单上吗?
最佳答案
Adding User Controls to a Web Forms Page
您必须在 Page 指令
下面注册
控件,如下所示。
<%@ Register TagPrefix="Guest" TagName="GuestExample" Src="~/YourControl.ascx" %>
然后根据您的要求更改 TagPrefix
和 TagName
。
示例
<Guest:GuestExample ID="ID" runat="server" />
Instead of duplicating them on all your pages, just declare them once within the new pages->controls section with the web.config file of your application:
<?xml version="1.0"?>
<configuration>
<system.web>
<pages>
<controls>
<add tagPrefix="Guest" src="~/YourControl.ascx" tagName="GuestExample"/>
</controls>
</pages>
</system.web>
</configuration>
关于asp.net - 如何更改用户控件中的默认标签前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10201584/