D A Placeholder For Controls

You can use the Placeholder Web server control to hold other controls on your ASP.NET Web pages. This is a convenient way to specify where on your page you want to put controls. It is especially useful if you want to create all of your form controls programmatically.

You can use the Placeholder Web server control almost anywhere on your ASP.NET Web page. It does not have to be on a server form, but if you are adding controls for a form, you should make sure that it is between the <form> tags. You should then create the control and add the control to the placeholder using the Placeholder.Controls.Add method.

The Placeholder control does not generate any HTML back to the Web browser, but is used only to specify the location of controls that you add at runtime. Placeholder controls are very useful in dynamically loading controls on a Web page. If you do not know which control should be on the page or how many controls should be on the page until the page is requested, then you should use the Placeholder control.

USE A PLACEHOLDER FOR CONTROLS

USE A PLACEHOLDER FOR CONTROLS

D Open the WebVisitHomepage Template.aspx template from the Code Templates directory.

~~0 Create an HTML server control and set its properties

'—Q Add the control to the Placeholder control.

0 Save the file and request it from the Web server.

The HTMLAnchor control appears where the placeholder is located.

D Open the WebVisitHomepage Template.aspx template from the Code Templates directory.

~~0 Create an HTML server control and set its properties

'—Q Add the control to the Placeholder control.

0 Save the file and request it from the Web server.

Note: See pages 20 to 25 for instructions on saving a file to the Web server and then requesting the file using the IIS Admin.

The HTMLAnchor control appears where the placeholder is located.

PROVIDE A CONTAINER FOR CONTROLS

The Panel control can be used as a container for other controls on your ASP.NET Web pages. The control is very useful if you wish to hide a specific group of controls.

The Panel Web control resides on a server form on your ASP.NET page. The Panel control is created with the <ASP: Panel> tag. You will need an id attribute to give the control a name, which is how you reference it in code. You can set the initial value of attributes when you declare the control. For example, you can set the visible attribute to False, which would initially hide the control.

PROVIDE A CONTAINER FOR CONTROLS

You use the Panel control to break the Web page into sections of the Web page the user can view. Therefore, you treat the Panel control as a container for other controls. As the user interacts with your page, you can hide Panels or make them visible. This gives the effect of seeing multiple pages, when in fact they are viewing different Panels of the same page.

For example, you can create a page that first displays one panel. When the user finishes the page and clicks a Submit button, the first panel can be hidden and the second panel can be displayed. This would give users the impression that they have moved to another page.

PROVIDE A CONTAINER FOR CONTROLS

D Open the

GenericTemplate.aspx template from the Code Templates directory.

□ Create a Panel control and give it an ID.

—0 Add a button for the user to click and call the Button_OnClick function for the onClick event.

0 Add a message to the user about being on the second step.

D Open the

GenericTemplate.aspx template from the Code Templates directory.

~~0 Add a heading for the page.

L-H Create a server form.

□ Create a Panel control and give it an ID.

—0 Add a button for the user to click and call the Button_OnClick function for the onClick event.

—0 Create a Panel control and give it an ID and set the VISIBLE attribute for the control to False.

0 Add a message to the user about being on the second step.

user.

Was this article helpful?

0 0

Post a comment