I am using asp.net 4, vs 2010.
I have a WebSite project, with some paged (apsx) and WebServices (asmx).
I am trying to use a custom UserControl that I included in my project.
The WebControl/UserControl is a plain c# class, with no aspx/ascx/asmx. This class is configured as follows:
public class DropDownMenu : UserControl
Meaning it extends System.Web.UI.UserControl, And it Overrides a bunch of UserControls
methods such as OnPreRender, OnLoad etc.
This file compiles OK, But I didn’t succeed in using it in an aspx file.
I tried the following:
<%@ Register TagPrefix="My" TagName="DropDownMenu"
Src="DropDownMenu.cs"%>
But this dosent work. I recieve a runtime error:
The file ‘src’ is not a valid here because it doesn’t expose a type.
Iv’e also tried
<%@ Register Assembly="DropDownMenu" Namespace="MyNameSpace" TagPrefix="My" %>
and I recieved a run time error
Could not load file or assembly ‘DropDownMenu’ or one of its dependencies. The system cannot find the file specified.
Does anyone knows how I can use my class as an asp tag/control?
I just want to use the following in an aspx page:
< My:DropDownMenu >
Registration:
Here
AssemblyandNameSpacecontain name of assembly and namespace where control’s class is defined, neither of them is the name of the control itself. Note that assembly name does not include file extension.Usage: