aspxtreme

@ Register

ASP.NET Syntax   ASP.NET Page Syntax   Page Directives


Associates aliases with namespaces and class names for concise notation in custom server control syntax.

<%@ Register tagprefix = "tagprefix" Namespace = "namespace"
   Assembly="assembly" %>
<%@ Register tagprefix = "tagprefix" Tagname = "tagname" 
   src = "pathname" %>

Attributes


tagprefix An alias to associate with a namespace.
tagname An alias to associate with a class.
Namespace The namespace to associate with tagprefix.
Src The location ( relative or absolute ) of the user control or user-defined custom server control associated with tagprefix:tagname.
Assembly The assembly in which the namespace you are associating with tagprefix resides.

NOTE: The assembly name does not include a file name extension.


Remarks

Use this directive when you are declaratively adding a custom ASP.NET server control to a page.

In custom server control syntax, tagname and tagprefix are always used in conjunction as a colon-separated pair ( tagprefix:tagname ). You can use tagprefix alone in a custom server control tag, but not tagname. If you use only the tagprefix attribute, you must include Assembly and Namespace attributes.

Syntax Example

The following code fragment uses <%@ Register %> directives to declare tagprefix and tagname aliases for a server control and a user control. The first directive declares the MyTag alias as a tag prefix for all controls residing in the MyCompany:myNamespace namespace. The second directive declares Acme:AdRotator as a tagprefix:tagname pair for the user control in the file Adrotator.ascx. The aliases are then used in custom server-control syntax within the form to insert an instance of each server control.

<%@ Register Tagprefix = "MyTag" Namespace = "MyCompany:myNamespace"
   Assembly = "myAssembly" %>
<%@ Register Tagprefix = "Acme" Tagname = "AdRotator" 
   src = "AdRotator.ascx" %>
<html>
 <body>
   <form runat="server">
      <MyTag:MyControl id="Control1" runat="server" />
<br>
      <Acme:AdRotator file = "myads.xml" runat="server" />
   </form>
 </body>
</html>
See Also

Web Forms User Controls



Books and more ...


Suggested Reading

Need a break ?



Previous page Back to top Next page

Check out related books at Amazon

© 2000-2008 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support aspxtreme