What are user controls?
- User controls are custom,
- reusable controls,
- Microsoft offer an easy way to partition and reuse common user interfaces across ASP.NET Web applications
<%@ Register TagPrefix="UC" TagName="TestControl" Src="test.ascx" %>
and add control
<html> <body> <form runat="server"> <UC:TestControl id="Test1" runat="server"/> </form> </body> </html>How to add RunTime:// Load the control by calling LoadControl on the page class. Control c1 = LoadControl("test.ascx"); // Add the loaded control in the page controls collection. Page.Controls.Add(c1);What are custom controls?
Custom controls are compiled code components that execute on the server,expose the object model,and render markup text,such as HTML or XML, as a normal Web Form or user control does.How to create Custom control:Ctrl+Shift+A=> Add class library=>render control => excute programUser Control vs Custom Control:
Factors | User control | Custom control |
Deployment | Designed for single-application scenarios | Designed so that it can be used by more than one application |
Creation | Creation is similar to the way Web Forms pages are created; well-suited for rapid application development (RAD) | Writing involves lots of code because there is no designer support |
Content | A much better choice when you need static content within a fixed layout, for example, when you make headers and footers | More suited for when an application requires dynamic content to be displayed; can be reused across an application, for example, for a data bound table control with dynamic rows |
Design | Writing doesn't require much application designing because they are authored at design time and mostly contain static data | Writing from scratch requires a good understanding of the control's life cycle and the order in which events execute, which is normally taken care of in user controls |
What is the Difference between user control & custom control in asp.net.....Please give me some example......