|
Panel
The Panel Web server control is used to contain other controls, say
a set of radio buttons, check boxes, etc. This is a very useful control which allows
us to show or hide a group of controls at once or add new controls to a page in code.
The class hierarchy for this control is as follows:
Object
Control
WebControl
Panel
Notable Properties
Notable properties of the Panel are as follows:
BackImageUrl: Gets/Sets the background image's URL for the
panel
HorizontalAlign: Gets/Sets the horizontal alignment of the
parent's contents
Wrap: Gets/Sets whether the panel's content wraps
Panel Sample
Drag a Panel on to the form. Drag two textboxes and a button on to the panel. The
following code does nothing special but demonstrates how to use panels. The code
displays the text you enter in textbox1 in textbox2 when the button is clicked.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_
System.EventArgs) Handles Button1.Click
TextBox2.Text = TextBox1.Text
End Sub
|
PlaceHolder
The PlaceHolder Web server control does not have any visible output and is used as
a place holder when we add controls at run time. The class hierarchy for this control
is as follows:
Object
Control
PlaceHolder
PlaceHolder Sample
Drag a PlaceHolder control on to the form. The following code will create two TextBoxes
and a Button in code and will add them to the place holder at run time when a button
is clicked. Open the code behind file for the web form and paste the following code:
Dim TextBox11, TextBox12 As New System.Web.UI.WebControls.TextBox()
Dim Button11 As New System.Web.UI.WebControls.Button()
'declaring two textboxes and a button
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_
System.EventArgs) Handles Button1.Click
TextBox11.Text = "Created TextBox11"
TextBox12.Text = "Created TextBox12"
Button11.Text = "Created Button"
'setting text for the textboxes and button
TextBox11.Columns = 15
TextBox11.ReadOnly = True
TextBox12.Columns = 20
PlaceHolder1.Controls.Add(TextBox11)
PlaceHolder1.Controls.Add(TextBox12)
PlaceHolder1.Controls.Add(Button11)
'adding the created textboxes and button to placeholder
End Sub
|
Live Code Demo
Panel Demo
Place Holder Demo
|