Difference between user controls and custom controls in .net (vb, c# net with asp.net)
User controls:
It is newly concept in .net it same like as inheritance concept in oops
In asp.net the base class is system.web.ui.page object
When ever creating user control that will be converting as a class, and this class become
Subclasses of System.web.ui.page class at compile time
User control extension with .ascx
Let us see program how build (at end I will mention difference between user control and
Custom control)
Custom control:
Creating user controls, which are essentially reusable small web pages,
You can also create your own compiled custom controls.
There are three ways to create custom controls:
1) Create a derived custom control by deriving from an existing control.
2) Create a composite control by grouping existing controls together into a new compiled control.
3) Create a full custom control by deriving from System.Web.UI.WebControls.WebControl
Composite controls are most similar to user controls. The key difference is that composite
Controls are compiled into a DLL and used as you would any server control.
Let us programmatically that will help how to build:
Iam explaining on simple example:
Take notepad example:
Imports System.ComponentModel
Imports System.Web.UI
("<{0}: WebCustomControl1 runat=server>")>
Public Class WebCustomControl1
Inherits System.Web.UI.WebControls.WebControl
Dim text As String
Property [Text]() As String
Get
Return text
End Get
Set(ByVal Value As String)
text = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
output.Write([Text])
End Sub
End Class
Now compile then it generate one dll
Now open IDE language is vb.net with asp.net
Just write in html of .vb page
<% @ Register Tag prefix=”raghu” namespace=”chinni” assembly= “WebControlLibrary1” %>
Now create instance
Under
<form>
<raghu:chinni ID=”tatcis” Text=”this is placid man”/><form>
Now press F5
U gets output as
this is placid man
Let us see differences
User control
1) Reusability web page
2) We can’t add to toolbox
3) Just drag and drop from solution explorer to page (aspx)
4) U can register user control to. Aspx page by Register tag
5) A separate copy of the control is required in each application
6) Good for static layout
7) Easier to create
8)Not complied into DLL
9) Here page (user page) can be converted as control then
We can use as control in aspx
Custom controls
1) Reusability of control (or extend functionalities of existing control)
2) We can add toolbox
3) Just drag and drop from toolbox
4) U can register user control to. Aspx page by Register tag
5) A single copy of the control is required in each application
6) Good for dynamics layout
7) Hard to create
8) Compiled in to dll
===============================
URL
http://www.dotnetspider.com/resources/1914-Difference-Between-usercontrol-custom-control.aspx
http://www.dotnetfunda.com/interview/exam379-difference-between-custom-control-and-user-control-.aspx
http://jalpesh.blogspot.com/2009/05/what-is-difference-between-user-control.html
--------------------------------------------
DIFFERENCE BETWEEN MACHINE.CONFIG AND WEB.CONFIG
----------------------------------------------------
Web.Config..
1.In web.config we can store,
Database Connection
Session State
Error handling
Security
Machine.Config..
1.In machine.config we can store,
Connection strings
Membership
Role Manager
Profile
HTTP Handlers
For More Details..
http://www.geekinterview.com/question_details/21032
http://www.geekinterview.com/question_details/39708
http://www.allinterview.com/showanswers/56550.html
------------------------------------------------------------
No comments:
Post a Comment