Use of Register Directives in ASP.Net
Why we use @Register Directives in ASP.Net
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Hemant KumarRank #1,202 · 1.5K reputationPosted Oct 24, 2011, 9:50 PM EDT
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 ascxextenstion. 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 in ASP.NET
<%@ Register TagPrefix="UC1" TagName="UserControl1" Src="UserControl1.ascx" %>
The TagPrefix attributes is used to specify a unique namespace for the user control. TheTagName 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...
Uma Shankar PatelRank #3,213 · 447 reputationPosted Oct 24, 2011, 9:47 PM EDT
we use Register directive to register dll/custom controls with our application/website.
Prabhu RajaRank #861 · 2.6K reputationPosted Oct 24, 2011, 11:55 PM EDT
@Register directive informs the compiler of any custom server control added to the page.