Web Tutorials

Interview Q & A

Code Examples

Utility Tools

ASP.NET Register Directive Attributes

ASP.NET Register Directive is used to register and use user control in aps.net page.

Syntax

<%@ Register attribute="value" [attribute="value"...] %>    

Register Directive Attributes

AttributesDescription
AssemblySpecifies the assembly you want to associating with the TagPrefix.
NamespaceSpecifies the namespace to relate with TagPrefix.
SrcSpecifies the user control.
TagNameSpecifies alias name to relate to your class name.
TagPrefixSpecifies alias name to relate to the namespace.

ASP.NET Register Directive Attributes User Control Example

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CalendarUserControl.ascx.cs" 
Inherits="CalendarUserControl" Description="This is Calendar user control."%>
<asp:calendar id="Cal" runat="server" /%>

ASP.NET Register Directive Attributes Example C#

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="homePage.aspx.cs" 
Inherits="homePage" %>
<%@ register tagprefix="uc1" tagname="CalendarUserControl" 
src="~/CalendarUserControl.ascx" %>  
<!DOCTYPE>
<html>
<head runat="server">
    <title>Calendar Page</title>
</head>
<body>
  <form id="form1" runat="server">
    <uc1:calendarusercontrol runat="server" />
  </form>
</body>
</html>  

ASP.NET Register Directive Attributes Example VB

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="homePage.aspx.vb" 
Inherits="homePage" %>
<%@ register tagprefix="uc1" tagname="CalendarUserControl" 
src="~/CalendarUserControl.ascx" %>     
<!DOCTYPE>
<html>
<head runat="server">
    <title>Calendar Page</title>
</head>
<body>
  <form id="form1" runat="server">
    <uc1:calendarusercontrol runat="server" />
  </form>
</body>
</html>

RequiredFieldValidator

RegularExpressionValidator

RangValidator

CompareValidator

CustomValidator

ValidationSummary