Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Thursday, August 25, 2011

doubt...User Controls VS Custom Controls


Hi Ravi,
 

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
How to create User Control,
 
Ctrl+Shift +A  => Add Usercontrol ==> Design control
 
Rules For creating user controls:
 
The syntax you use to create a user control is similar to the syntax you use to create a Web Forms page (.aspx).
The only difference is that a user control does not include the <html>, <body>, and <form> elements since a Web Forms page hosts the user control.
 
How to Add your User Control;
 
you can register your control in particular  your page
<%@ 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 program
 
User Control vs Custom Control:
 
 
 
 

Factors

User control

Custom control

Deployment

Designed for single-application scenarios

Deployed in the source form (.ascx) along with the source code of the application

If the same control needs to be used in more than one application, it introduces redundancy and maintenance problems

Designed so that it can be used by more than one application

Deployed either in the application's Bin directory or in the global assembly cache

Distributed easily and without problems associated with redundancy and maintenance

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

 
 
Reference :
 
Micrsoft
 
Thanks to Micrsoft 
  
On Thu, Aug 25, 2011 at 3:37 PM, ravi kumar <ravidravi@gmail.com> wrote:
  
What is the Difference between user control & custom control in asp.net.....Please give me some example......
 

No comments: