Today in this tutorials we will learn about user controls and custom controls. So let's start from user controls.
User Controls:-
A user control also can be used a normal server control. Basically user controls are made by user as per their requirements. If a user need to show a news section on all page and should be same on all pages then we can make a user control and put this on all pages. If there is a change in control user will change in control file and it will be replicated to all pages.it is also a best example of code re-usability.
In Asp.net we have System.Web.UI.UserControl class which is used to create user controls.
User control extension is .ascx. A user control cannot have HTML, body or form tags and at the top there is control directive instead of page as used in normal asp.net pages.
Custom Controls:-
Customer control are basically written by user or derived from any third party. Customer control becomes an individual assembly when deployed and after compilation it becomes a DLL (Dynamic Link Library). These can be used as other asp.net server controls. These are used in asp.net web forms and a custom client control used in asp win forms applications. There are different ways to create custom control like:
- Derive a customer control from asp.net control
- We can compose 2 or 3 asp.net control to derive a new custom control
- We can make custom control from base control class of asp.net
No comments:
Post a Comment