HOME

ASP.NET Tutorial
ASP.NET HOME
ASP.NET Intro
ASP.NET vs ASP
ASP.NET Install
ASP.NET Pages
ASP.NET Controls
ASP.NET Events

References
HTML Controls
Web Controls
Validation Controls
Award Winning Web Host Full Services Including Ecommerce
Please visit our sponsors !

Panel Control

Back

Definition and Usage

The Panel control is used as a container for other controls.

Tip: This control is often used to generate controls by code and to display and hide groups of controls.

Note: This control renders as an HTML <div> element.


Properties

Property Description
BackImageUrl Specifies a URL to an image file to display as a background for this control
HorizontalAlign Specifies the horizontal alignment of the content. Legal values are:
  • Center
  • Justify
  • Left
  • NotSet
  • Right
id A unique id for the control
runat Specifies that the control is a server control.  Must be set to "server"
Wrap A Boolean value that specifies whether the content should wrap or not

Example 1

In the following example we declare one Panel control, one DropDownList control, one CheckBox control, and one Button control in an .aspx file. When the user checks the CheckBox control, and the clicks the Refresh button, the Panel control will hide. The user can also choose how many text-boxes that should be displayed in the Panel control, by selecting a number in the drop-down list:

<script runat="server">
  Sub Page_Load(sender As Object, e As EventArgs)
    if chk.Checked then
      p.Visible=false
    else
      p.Visible=true
    end if
    dim n,i
    n=txtbox.SelectedItem.Value
    for i=1 to n
      Dim t As New TextBox()
      t.Text="TextBox " & i
      p.Controls.Add(t)
      p.Controls.Add(New LiteralControl("<br>"))
    next
  End Sub
</script>
<html>
<body>
<form runat="server">

<asp:Panel id="p" runat="server" BackColor="yellow"
Height="200px" Width="200px">Hello World!!!!!!!!!!!!
</asp:Panel>

<p>Create TextBoxes:
<asp:DropDownList id=txtbox runat="server">
<asp:ListItem Value="0">0</asp:ListItem>
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
</asp:DropDownList>
</p>
<p>
asp:CheckBox id="chk" Text="Hide Panel control"
runat="server"/>
</p>
<p>
<asp:Button Text="Refresh" runat="server"/>
</p>

</form>
</body>
</html>


Back

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

IISProtect
Password Protect
Your Web Pages



Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search