Web User Controls - Creation and Implementation

Creating a user control is similar to that of the web page except that the control page has an extension .ascx. If you are creating the user control using the Visual Studio .Net IDE, then these are taken care of automatically.

To create a user control, create a file with the extension .ascx and add a @control directive at the top of the page. Give a ClassName attribute to that directive and give a class name. Now add the controls that are needed for your user control and add the functionalities needed to be performed by these controls. Now if needed, you can create properties using public members are using the get and set routines.

Having created the user control, now it is time that you use it in a web page. To use a user control in a web page you have to register it first. Use the @register directive to register the user control and add the attributes like TagPrefix, and TagName to it. The syntax for the register directive would be,

<%@ Register TagPrefix="some_prefix" TagName="some_name_for_the_ctrl"
Src="the_.ascx_pagename" %>

Now you can use the user control in any part of the web page by using the syntax,

<TagPrefix:TagName runat="server" />





______________________________________________________

Recommended Resource



| Converting Web Pages to User Controls in .NET | .Working on .NET User Controls | Overview of ASP.NET User Controls | Web User Controls - Creation and Implementation | Advantages of using User Controls in ASP.NET | Re-usability of User Controls in ASP.NET | Personalizing Web Application by Creating User Controls in .NET | Customizing your Application with VB.net User Controls | Building User Controls in ASP.NET | Examples of User Controls in VB.NET | Example of C# User Controls | Where to use Visual Basic User Controls | Working on User Interface Controls | Creating Dynamic User Controls | Understanding VB .NET User Controls | Creating User Controls VB.NET | How to load user controls dynamically |



_______________

FREE Subscription

Stay Current With the Latest Technology Developments Realted to .NET. Signup for Our Newsletter and Receive New Articles Through Email.

Name:

Email:

Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.


 

| Privacy Policy for www.dotnet-guide.com | Disclosure | Contact |

Copyright - © 2004 - 2017 - All Rights Reserved.