Pages

Wednesday, February 16, 2011

16/02 User Control:


Date 16-2-11 Wednesday

User Control: - These are controls that are created or developed by the programmers. To consume under your application there are of two types –
1.       
    Creating a new control from existing controls.
2.       
      - Inherited or Extended Controls.

- In the first case, we create new controls making use of existing controls, so to design the control first we need to define a class inheriting from the predefined class i.e. user control, which provide the container required for designing.

** Image con not be displayed


Syntax -
public class StopClock : UserControl
{
  // Design the control
  // write behavior for the control
}
 
- In the second case without designing any control we only copy the design of an existing control and add functionalities or behavior to the control.

In this case, we define a class inheriting from the control class and we have to add new behavior.

public class NumericTextBox : TextBox
{
   // write the code for accepting only numeric’s
}


Note – To create a control in the first process we need to add an item template of the type user control, which provide a class inheriting from UserControl class.
            Where as in the second case we need to add a item template of type class and than
Inherit from the control class we want to extend. 

0 comments:

Post a Comment