What is the @Register directive used for? What is the purpose of @Register directive in ASP.NET?
How to create Web User Controls in ASP.NET?
Good developers must know the Register and User Control concept before any interview in ASP NET.
Directives in ASP.NET are used to set attributes for a page. The @Register
directive is a directive used to register user defined controls on a web page. A user created
server control has an ascx extenstion. These controls inherit from the namespace
System.Web.UI.UserControl. This namespace inherits from the System.Web.UI.Control.
A user control may be embedded in an aspx web page using the @Register directive.
A user control cannot be executed on its own independently, but may be registered on a web page
and then used out there. Below is the syntax for registering an @register directive in an aspx page
<%@ Register TagPrefix="UC1" TagName="UserControl1" Src="UserControl1.ascx" %>
The TagPrefix attributes is used to specify a unique namespace for the user control. The
TagName is a name used to refer a user control uniquely by its name. Say we want to use this
control in a webpage, we may use the code below...
Values Between Pages
Page Life Cycle