Directive used in Custom Controls
Which directive is used to add a custom control in the web form?
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 attend5days leftRegister
Priya LingeRank #785 · 2.9K reputationPosted Oct 17, 2011, 9:08 PM EDT
Register directive attributes used to add custom controls to a Web form.
<%@ Register %> directives
TagPrefix: The TagPrefix defines a unique namespace for an user control. If multiple user controls are present on the page having same name, then they can be differentiated with them by using this directive. It determines the group that the user control belongs to.
Namespace: It is nothing but the project name and namespace within the custom control assembly that contains the controls to register. The .NET applications use the project name as an implicit namespace for controls present in the application.
Assembly: This defines the name of the created assembly (.dll) that contains the custom controls. The control assembly is referenced by the Web application and it maintains a copy in the web applications 'Bin' directory.
<%@ Register TagPrefix="scott" TagName="header" Src="Controls/Header.ascx" %>
<%@ Register TagPrefix="scott" TagName="footer" Src="Controls/Footer.ascx" %>
<%@ Register TagPrefix="ControlVendor" Assembly="ControlVendor" %>
Hope this will help you.
Thanks.
Hemant KumarRank #1,202 · 1.5K reputationPosted Oct 17, 2011, 9:04 PM EDT
@Registeris the more commonly used directive. You use this when you want to use a user control in your aspx or ascx page declaratively.@Registerassociates the control with a specific prefix and you can then use it in your markup.@Referenceonly tells ASP.NET to compile the other control when your aspx or ascx page is compiled. That makes sure it is available at run-time and can be added to your control hierarchy programmatically. This is less common.Here's a good blog post about it.
http://weblogs.asp.net/johnkatsiotis/archive/2008/08/13/the-reference-directive.aspx
TulasiRank #2,544 · 549 reputationPosted Oct 17, 2011, 9:12 PM EDT
we have to add the custom control to the toolbox so that you can use it in a Web page in the test Web site.
steps to add
The customcontrol1 appears in the Toolbox.
drag a custom server control from the toolbox to an .aspx page,
chk the below link to change Tagprefix for the server control(custom control)
http://msdn.microsoft.com/en-us/library/yhzc935f.aspx
Please mark the answer as Accepted if it helps you.
Prabhu RajaRank #861 · 2.6K reputationPosted Oct 17, 2011, 9:51 PM EDT
As per everyone says Register Directive is used to add custom control to web form. I suggest you to take a look into this Article, to know more.
http://www.c-sharpcorner.com/UploadFile/jayendra/528/