.NET FAQs Unleashed!
Skip Navigation Links
Interview questions on Design Patterns in .NET
ASP.NET Ajax Interview Questions
Interview questions related to security
C# Interview Questions
ASP.NET Interview Questions
Interview Questions in ASP.NET 2.0
Articles at dotnetuncle.com
Skip Navigation Links
OOPs questions in .NET
Questions on .NET Framework
ADO.NET Interview Questions
Short Answer questions in .NET
Frequently asked differences in .NET
Important commonly used Acronyms in .NET
MS SQL, Oracle SQL Interview Questions
 
    
Dotnetuncle's Tip:

  A field is essentially a member of a struct or a class. A field can have the following modifiers: public, internal, private, protected, static, new, unsafe, readonly, volatile

    

What is the @Register directive used for? What is the purpose of @Register directive in ASP.NET? How to create Web User Controls in ASP.NET?

Good developers must know the Register and User Control concept before any interview in ASP NET.
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 ascx extenstion. 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. The TagName 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...

<UC1:UserControl1 runat="server"/>

1  Page Redirection  Values Between Pages  Worker Process  Page Life Cycle  Global Variables  Postback  Server Control  Viewstate  Send Email  Namespace  Localization  Event Handler  Validation  Global.asax  HttpHandler  Session  Cookie  EnableViewState  Smart Navigation  Web Farm  Dataset  Register 


    
Dotnetuncle's Tip:

  In C Sharp, Type Safety is enforced during compile time. Yet the new keyword called dynamic can be used to enforce type safety at runtime. The keyword dynamic is introduced in .NET 4.0.