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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Priya LingePosted Oct 18, 2011, 1:08 AM
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.
Prabhu RajaPosted Oct 18, 2011, 1:51 AM
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/
TulasiPosted Oct 18, 2011, 1:12 AM
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.
Hemant KumarPosted Oct 18, 2011, 1:04 AM
@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