如何将Web用户控件放在工具箱中?

时间:2013-05-16 11:14:54

标签: c# asp.net webusercontrol

[ToolboxData("<{0}:WebUserControl1 runat=\"server\"></{0}:WebUserControl1>")]  
[ToolboxItem(true)]  
public partial class WebUserControl1 : System.Web.UI.UserControl    

当我把它拖出来并放到aspx时什么也没发生。 当然我已经将它转换为自定义控件Turning an ascx user control into a redistributable custom control

1 个答案:

答案 0 :(得分:0)

AFAIK您无法将ascx添加到Toolbox。如果那是Windows窗体应用程序用户控件将自动显示在那里。 David的帖子是关于将Web用户控件编译为单独的dll(仅适用于其网站,而不是Web应用程序)并重复使用它。只有选项才能使其成为复合控件以显示在工具箱中。

How to drag a UserControl into the Toolbox?