C# 将用户控件添加到asp.net页面
我使用如下事件创建一个用户控件:C# 将用户控件添加到asp.net页面,c#,asp.net,user-controls,asp-usercontrols,C#,Asp.net,User Controls,Asp Usercontrols,我使用如下事件创建一个用户控件: public partial class Person : System.Web.UI.UserControl { public delegate void EditPersonHandler(object sender, EditPersonEventArgs e); public event EditPersonHandler EditPerson; protected void Page_Load(object sender, Ev
public partial class Person : System.Web.UI.UserControl
{
public delegate void EditPersonHandler(object sender, EditPersonEventArgs e);
public event EditPersonHandler EditPerson;
protected void Page_Load(object sender, EventArgs e)
{
}
}
这是我的编辑文塔格:
public class EditPersonEventArgs:EventArgs
{
private int id;
public int ID
{
get { return id; }
set { id = value; }
}
public EditPersonEventArgs(int ID)
{
id = ID;
}
}
现在,我想将此用户控件添加到我的页面,并执行以下操作:
<%@ Register TagPrefix="UControl" TagName="UControlPerson" Src="~/SimpleUC/Person.ascx" %>
<div>
<UControl:UControlPerson ID="UControlPerson" runat="server"
OnEditPerson="UControlPerson_EditPerson" />
</div>
我构建了解决方案。
但是,当我呈现页面时,会出现以下错误:
Description: An error occurred during the compilation of a resource required to service this
request. Please review the following specific error details and modify your source code
appropriately.
Compiler Error Message: CS0426: The type name 'SimpleUC' does not exist in the type
'System.Web.UI.UserControl'
这是我的名字空间:
namespace UserControl.SimpleUC
如果出现名称空间冲突,则用户控件名称空间UserControl的UserControl.SimpleUC
部分将解析为名称空间System.Web.UI.UserControl
解决此问题的最简单方法是为控件选择另一个命名空间。可能类似于UserControls.SimpleUC
Description: An error occurred during the compilation of a resource required to service this
request. Please review the following specific error details and modify your source code
appropriately.
Compiler Error Message: CS0426: The type name 'SimpleUC' does not exist in the type
'System.Web.UI.UserControl'