asp.net - 如何更改用户控件中的默认标签前缀

标签 asp.net

当您将 Web 用户控件拖到设计图面上时,它将自动分配 tagprefix = uc1。

有谁知道如何更改所有网络用户控件的默认标签前缀 您将其拖到网络表单上吗?

最佳答案

Adding User Controls to a Web Forms Page

您必须在 Page 指令 下面注册控件,如下所示。

<%@ Register TagPrefix="Guest" TagName="GuestExample" Src="~/YourControl.ascx" %>

然后根据您的要求更改 TagPrefixTagName

示例

<Guest:GuestExample ID="ID" runat="server" />

enter image description here


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/

相关文章:

c# - 使用 MySQL 在 ASP.NET 中登录错误

c# - 何时使用 Literal 与 LiteralControl?

asp.net - 为什么我的 RouteTable.Routes 属性是 System.Web.Routing.RouteCollection 的实例而不是 System.Web.Http.HttpRouteCollection 的实例?

c# - ASP.NET Core 3.0 中发生错误请求错误时显示错误属性

c# - Entity Framework 中的异常处理

asp.net - DropDownList 内容出现在引擎搜索结果中

c# - 如何包装和替换 ASP.NET 5 配置中的默认组件之一

c# - 在 chrome 中滚动 ListBox 时回发

javascript - 将文件从 JQuery Ajax 发送到 C# Webmethod

c# - asp.net c# mysql select 语句中的方括号