PlaceHolder Control in ASP.NET using VB.NET

This article shows the PlaceHolder control in ASP.NET.
  • 2576

This article shows the PlaceHolder control in ASP.NET.

PlaceHolder Control

The PlaceHolder control is used to reserve space for controls added by code. The PlaceHolder control does not produce any visible output (it only acts as a container for other controls on the Web page).

Property window:


Figure 1.

For example

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.

Form looks like this.


Figure 2.

Now double click on the button and add following code.

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

        TextBox1.Text = "Created TextBox11"

        TextBox2.Text = "Created TextBox12"

        Button1.Text = "Created Button"

        'setting text for the textboxes and button

        TextBox1.Columns = 15

        TextBox1.ReadOnly = True

        TextBox2.Columns = 20





        'adding the created textboxes and button to placeholder

    End Sub

End Class


Now save and run the application.



Figure 3.


Now click on the button.



Figure 4.


The above figure displays that placeholder contains textboxes and button control.                


More Articles

© 2020 DotNetHeaven. All rights reserved.