【问题标题】:What assembly are ASP.NET UserControls put into?ASP.NET UserControls 放入了哪些程序集?
【发布时间】:2009-02-07 11:32:24
【问题描述】:

我在 ~/App_Code 中创建的类被放入 App_Code 程序集中。

如果我创建以下 ASP.NET 用户控件:

~/UserControls/BasicUserControl.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="BasicUserControl.ascx.cs" Inherits="UserControl_BasicUserControl" %>
Hello world!

~/UserControls/BasicUserControl.ascx.cs

using System;

public partial class UserControl_BasicUserControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

将此动态 ASP.NET UserControl 添加到哪个程序集?

【问题讨论】:

    标签: asp.net user-controls


    【解决方案1】:

    构建您的网站,然后检查 ASP.UserControls_BasicUserControl_ascx 命名空间/类

    每次您对 .ascx 进行更改时,您都必须构建项目以使更改显示在智能感知中

    【讨论】:

    • 你说的是预编译网站吗?这里解释了这种技术 - blogs.msdn.com/davidebb/archive/2005/10/30/487160.aspx 这是唯一可用的方法吗?
    • 不预编译只是为了让 Visual Studio intellisense 获取构建项目所需的控件(我假设它必须在生成的程序集中使用反射来列出成员)
    【解决方案2】:

    如果您打开新创建的 UserControl 程序集,您会发现 UserControl 的命名空间是 ASP。因此,这意味着当使用 register 指令在页面上注册用户控件时,您必须将命名空间称为 ASP。之后编译并重建您的应用程序,您将获得智能感知支持。

    我已经制作了一个关于这个场景的视频,让我知道,我会发布一个链接。

    【讨论】:

      猜你喜欢
      • 2021-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-17
      • 2016-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多