I create a user control with an event like this :
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)
{
}
}
and this is my EditPersonEventArgs :
public class EditPersonEventArgs:EventArgs
{
private int id;
public int ID
{
get { return id; }
set { id = value; }
}
public EditPersonEventArgs(int ID)
{
id = ID;
}
}
And now i want to add this User control to my page and i do this :
<%@ Register TagPrefix="UControl" TagName="UControlPerson" Src="~/SimpleUC/Person.ascx" %>
<div>
<UControl:UControlPerson ID="UControlPerson" runat="server"
OnEditPerson="UControlPerson_EditPerson" />
</div>
and this my Function to handle the OnSavePerson :
protected void UControlPerson_EditPerson(object sender, EditPersonEventArgs e)
{
}
I built the solution.
but when I render the page i get this error:
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'
this is my name space:
namespace UserControl.SimpleUC
You have a namespace conflict, the
UserControlpart of your user control namespaceUserControl.SimpleUCis being resolved as the name spaceSystem.Web.UI.UserControl.The easiest way to resolve this issue would be to choose another namespace for your control. Possibly something similar like
UserControls.SimpleUC