Monday, December 29, 2008

WebCustom Control VS WebUser Control

Here is the steps to create the custom control.To implement this create two projects

To create Custom Control
1. On the File menu, point to New, and then click Project.The New Project dialog box appears.
2. In the ProjectTypes pane, choose either Visual Basic Projects or Visual C# Projects. Select Web Control Library in the Templates pane.
3. Change the Name to CustomLabel and click OK. The new project is created, and WebCustomControl1 opens in the Code Editor. Code for a custom Label control is included in the Web Control Library template by default.
4. On the Build menu, click Build CustomLabel to compile the control.The control is compiled as CustomLabel.dll. By default, it is created in the Bin folder inside the CustomLabel project folder.
5. Save the file.Now the Default Label is created

To create WebForm
1)On the File menu, point to Add Project, and then click New Project.The Add New Project dialog box appears.
2) In the Project Types pane, choose either Visual Basic Projects or Visual C# Projects. Select ASP.NET Web Application in the Templates pan
3)Click OK.
The new project is created

Adding Control to the Toolbox:
1)Right click on the ToolBox,Select Choose Item
2)You will find the .netFrameWorkComponent tab, select Browse and map the webusercontrol dll
3)Click Ok
4)Now You can find the WebuserControl in the tool box .
5)Double Click on the control or register the control with the following Tag
<%@ Register Assembly="CustomLabel " Namespace="CustomLabel " TagPrefix="cc1" %>
6)Now Run Your Project

Web User Controls vs. Web Custom Controls
Web User Control:
1)Easier to Create.
2)Limited support for consumers who use a visual design tool.
3)A separate copy of the control is required in each application.
4)Cannot be added to the Toolbox in Visual Studio.
5)Good for static layout.

Web Custom Controls
1)Harder to create.
2)Full visual design tool support for consumers.
3)Only a single copy of the control is required, in the global assembly cache.
4)Can be added to the Toolbox in Visual Studio.
5)Good for dynamic layout.

No comments: