我用这样的事件创建了一个用户控件:
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)
{
}
}
这是我的 EditPersonEventArgs :
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>
这是我处理的函数OnSavePerson
:
protected void UControlPerson_EditPerson(object sender, EditPersonEventArgs e)
{
}
我建立了解决方案。但是当我渲染页面时,我得到了这个错误:
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