Compartilhar via


How to: Add Panel Controls to a Web Forms Page

To use a Panel Web server control, you add it to a page and then add controls and static text to the control.

To add a Panel control to a Web Forms page

  1. In Design view, from the Standard tab of the Toolbox, drag a Panel control onto the page.

  2. To create static text, click inside the control and type. To add controls, drag them from the Toolbox into the Panel control.

    Note

    To add static text to the Panel control at run time, you create a Literal control and set its Text property. You then programmatically add the Literal object to the panel the way you would any control. For details about adding controls, see How to: Add Controls to an ASP.NET Web Page Programmatically.

  3. Optionally, drag the panel's borders to resize the control.

    Note

    The control automatically resizes itself to display all of its child controls, even if they exceed the height that you have set.

  4. Optionally, set the properties of the Panel control, which are described in the following table, to specify how the pane interacts with its child controls.

    Property

    Description

    HorizontalAlign

    Specifies how the child controls are aligned within the panel (left, right, centered, or justified).

    Wrap

    Specifies whether content that is too wide for the panel is wrapped to the next line or truncated at the panel's edge.

    Direction

    Specifies whether the content of the control renders left-to-right or right-to-left. This can be useful for creating areas on the page that have a different direction than the page as a whole.

    ScrollBars

    If you have set the Height and Width properties to constrain the Panel control to a specific size, you can add scrollbars by setting the ScrollBars property.

    GroupingText

    Renders a border and title around the Panel control.

    Note

    Setting the GroupingText property causes scrollbars not to appear, if you have specified them

See Also

Reference

Panel Web Server Control Overview