| Different between MasterPages and UserControl
Both of these provide a common design which is used in .aspx pages. We can pass data from both of this to .aspx pages and viceversa.
MasterPage:-(1)Files in master page have .Master extension which is comes in ASP.NET 2.0. It has code file master.cs or master.vb extension. And this can use all toolbox controls.
UserControl:-(1) This have .ascx extension. And code files are .aspx.cs or .ascx.vb. And this can use all toolbox controls.
MasterPage:-(2)This have a control name ContentPlaceHolder which have a storage location where we can put out contents of .aspx page. Common part for pages will be outside of ContentPlaceHolder. It can be increase or decrease as per our needs.
UserControl:-(2)This doesnot have any ContentPlaceHolder control so layout of this have some difficult in providing proper layout and alignment for large designs.
MasterPage:-(3)We need to add MasterPageFile attribute in the page directive of the .aspx page. The .aspxpage that uses the master page is known as content page.
UserControl:-(3)When we drag and drop a user control on page it is automatically Register and a Register Tag is added.
MasterPage:-(4)We can refernce using Web.Config file and we can do dynamically by writing code in preInit event.
UserControl:-(4)Can be attached dynamically using LoadControl method.
MasterPage:-(5)More suitable for large designs
UserControl:-(5)Suitable for small design
And one of main difference is thet we use UserControl in MasterPages. But MasterPages cannot be used in User Controls. | | |