.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> .NET Framework >> Post New Question Subscribe to Interview Questions

What is the difference between a web part and a user control?

Posted By :volvo     Posted Date :November 28, 2013    Points :40   Category :.NET Framework 
One of the limitations of user control is that they cannot be shared across web applications but they can be created using a designer tool. On the other hand if you take custom controls, they can be shared across web applications, but there is no visual designer for creating custom controls through which we cannot drag and drop custom controls. By now, we understand that there is a need to have a solution that would combine the features of both the user controls and custom controls. The solution which will solve this issue is Web Parts.

Web Parts are prefabricated components that are basically targeted at easing the job of portal site / collaboration sites development. They are basically server-side controls that run inside the context of special pages (known as Web Part pages) within an ASP.NET application or a WSS (Windows SharePoint Services) site. Web parts combine the flexibility of user controls and custom controls. Developers can drag completed Web Parts from Web Part galleries and drop them into Web Part zones. It can also be said that web parts add more value over other types of ASP.NET controls in that they add extra dimensions of user customization and personalization.

A bare ASP.NET ascx control would have to be added to a custom layout page. This limits the utility of the control a little as it cannot be added "just anywhere".

Having a webpart gives the flexibility of the control being added to the site multiple times in different locations or even multiple times on the same page with different properties.

When it comes to editors using the site, it makes a lot of difference for them to be able to add a webpart compared to editing a page layout, publishing it and then creating pages based on that page layout, so from the perspective of a site editor, the difference in usability is really quite large.

You can also find related Interview Question to What is the difference between a web part and a user control?  below: 

Difference Between User Control and Custom Control In Asp.Net?

  
User Controls: We need to implement with Predefined Functionality with Available Properties

Web User Controls:Web User Controls Implements Customized Properties and Customized Methods,we can develop any control with User defined Properties








(More...)

What is the difference between Custom Control and User Control

  
Custom Controls are compiled code (Dlls), easier to use, difficult to create, and can be placed in toolbox. Drag and Drop controls.

Attributes can be set visually at design time. Can be used by Multiple Applications (If Shared Dlls), Even if Private can copy to bin directory of web application add reference and use. Normally designed to provide common functionality independent of consuming Application.

User Controls are similar to those of ASP include files, easy to create, can not be placed in the toolbox and dragged - dropped from it. A User Control is shared among the single application files. (More...)

What is a user control?

  
An ASP.NET user control is a group of one or more server controls or static HTML elements that encapsulate a piece of functionality. A user control could simply be an extension of the functionality of an existing server control(s) (such as an image control that can be rotated or a calendar control that stores the date in a text box). Or, it could consist of several elements that work and interact together to get a job done (such as several controls grouped together that gather information about a user's previous work experience). (More...)

What is different between Web User Control and in Web Custom Control?

  
Web user controls : Web User Control is Easier to create and another thing is that its support is limited for users who use a visual design tool one gud thing is that its contains static layout one more thing a seprate copy is required for each application.

Web custom controls: Web Custom Control is typical to create and gud for dynamic layout and another thing is it have full tool support for user and a single copy of control is required because it is placed in Global Assembly cache. (More...)

whats the difference between a stroed procedure and a user defined function

  
udf ll return only one output parameter where as sp returns more(2100 not sure)

udf are called directly by their name in a pgm where as exec spname
is used to execcute an sp (More...)

How to use a user control in a Web Forms page

  
Declare the @ Register directive.

For example, use the following code.
<%@ Register TagPrefix="UC" TagName="TestControl" Src="test.ascx" %>
(More...)

How to create an instance of a user control programmatically in the code behind file of a Web Forms page

  
Create a new Web Forms page in Visual Studio.
Navigate to the code behind file generated for this Web Forms page.
In the Page_Load event of the Page class, write the following code.
// 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);

(More...)

How a user control is processed

  
When a page with a user control is requested, the following occurs:

1)The page parser parses the .ascx file specified in the Src attribute in the @ Register directive and generates a class that derives from the System.Web.UI.UserControl class.

2)The parser then dynamically compiles the class into an assembly.
If you are using Visual Studio, then at design time only, Visual Studio creates a code behind file for the user control, and the file is precompiled by the designer itself.

3)Finally, the class for the user control, which is generated through the process of dynamic code generation and compilation, includes the code for the code behind file (.ascx.cs) as well as the code written inside the .ascx file.
(More...)

What are Events fired for User Control in ASP.NET ?

  
The Sequence of User controls Execution as follows.

OnInit of the user control
OnInit of the containing page
OnLoad of the containing page
OnLoad of the user control (More...)

How do you deploy a User Control in SharePoint ?

  

Ans. You deploy your User Control either by a Custom webpart, which will simply load the control on the page or can use tools like SmartPart, which is again a webpart to load user control on the page. User Control can be deployed using a custom solution package for the webapplication or you can also the control in the webpart solution package so that it gets deployed in _controlstemplate folder (More...)

Which is faster a WebPart or a User Control?

  
Ans. A WebPart renders faster than a User Control. A User Control in SharePoint is usually loaded by a webpart which adds an overhead. User Controls however, gives you an Interface to add controls and styles. (More...)

How would you pass user credentials while using SharePoint WebService from your Web Part or application.

  
Ans. The web service needs credentials to be set before making calls.

Examples:

listService.UseDefaultCredentials = true; // use currently logged on user

listService.Credentials = new System.Net.NetworkCredential("user", "pass", "domain"); // use specified user (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend