Onlineatoz.net | ToolBox Standard Control Panel

ToolBox Standard Control Panel

Panel Web Server Control

in ASP.NET environment,Panel Web Server Control can help you to act this control as a container within the page for other controls. By putting controls into a Panel control, you can control them as a unit — for example, hiding or showing them.

You can also use a Panel control to create a distinct appearance for a group of controls. This article expalains you how to work with the Panel Web server control.

Grouping set of control with Panel Control

You can grouping a list of controls and putting them in a Panel control and then manipulating the Panel control. For example, you can hide or show a group of controls inside a panel by setting the panel's Visible property.

Default Button Property

By using this property,You can perform click event when pressing enter key,You can put TextBox controls and Button controls inside the Panel control and then define a default button by setting the Panel control's DefaultButton property to the ID of a button in the panel. If users press ENTER while typing in a text box inside the panel, it has the same effect as if the user had clicked the specified default button. This can help users work more efficiently with entry forms.

Scrollbars Property

For including scrollbars to the Panel control, set the Height and Width properties to constrain the Panel control to a specific size, and then set the ScrollBars property.Some controls, such as the TreeView control, do not have built-in scrollbars. You can add scrolling behavior by placing the control in a Panel control.

To add a Panel control to a page
  • Type an <asp:Panel> element in the page.
  • The following properties of the Panel control helps you to specify how the panel interacts with its child controls.
    • 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.
    • ScrollBars -Specifies whether the contents of the control are rendered left-to-right or right-to-left.
    • GroupingText -Renders a border and title around the Panel control.

the following code snippets demonstrates Add Controls to an Page Programmatically

in .aspx.cs page,

private void page_load(object sender, System.EventArgs e)
{
DropDownList ddl1 = new DropDownList();
PlaceHolder ph1 = new PlaceHolder();
int numlabels = System.Convert.ToInt32(ddl1.SelectedItem.Text);
for (int i=1; i<=numlabels; i++)
{
Label myLabel = new Label();

myLabel.Text = "Label" + i.ToString();
myLabel.ID = "Label" + i.ToString();
ph1.Controls.Add(myLabel);
// Add a spacer in the form of an HTML
element.
ph1.Controls.Add(new LiteralControl("
"));
}
}
 
Related Links

Posted by: Admin
Posted on: 9/13/2011 at 1:53 PM
Categories: Asp.net
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed