aspnet-devexpress-dot-web-dot-aspxpanelcontainerbase.md
Gets a collection that contains child controls representing a panel’s content.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public ControlCollection Controls { get; }
Public ReadOnly Property Controls As ControlCollection
| Type | Description |
|---|---|
| ControlCollection |
A ControlCollection that contains a panel’s child controls.
|
The Controls property allows you to programmatically access the instance of the ControlCollection class which contains child controls that represent a panel’s contents. You can add controls to the collection, remove controls from the collection, or iterate through the server controls in the collection.
This example demonstrates how to use the SetVisible(visible) method and the client-side EndCallback event to show/hide controls implementing a simple verification wizard. You can implement the wizard by showing and hiding controls at each step and creating subsequent controls in the Callback event.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v14.2, Version=14.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>How to hide controls on client side after callback</title>
<script>
function SubmitRobotTest(s, e) {
CallbackPanel.PerformCallback();
}
function OnEndCallback(s, e) {
CaptchaLabel.SetVisible(false);
CaptchaRadioButtonList.SetVisible(false);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<dx:ASPxLabel ID="CaptchaLabel" ClientInstanceName="CaptchaLabel"
runat="server"
Text="Are you a robot? You have only one attempt!"
Width="200px">
</dx:ASPxLabel>
<dx:ASPxRadioButtonList ID="CaptchaRadioButtonList" ClientInstanceName="CaptchaRadioButtonList"
runat="server"
ValueType="System.Boolean"
SelectedIndex="0">
<Items>
<dx:ListEditItem Text="Yes" Value="true" />
<dx:ListEditItem Text="No" Value="false" />
</Items>
</dx:ASPxRadioButtonList>
<dx:ASPxButton ID="Button" runat="server" Text="Submit" AutoPostBack="false">
<ClientSideEvents Click="SubmitRobotTest" />
</dx:ASPxButton>
<dx:ASPxCallbackPanel ID="CallbackPanel" ClientInstanceName="CallbackPanel"
runat="server"
Width="200px"
OnCallback="CallbackPanel_Callback">
<ClientSideEvents EndCallback="OnEndCallback" />
</dx:ASPxCallbackPanel>
</form>
</body>
</html>
using System.Drawing;
using DevExpress.Web;
public partial class _Default : System.Web.UI.Page {
protected void CallbackPanel_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e) {
if((bool)CaptchaRadioButtonList.Value)
AddSuccessControlsInPanel(sender);
else
AddFailureControlsInPanel(sender);
}
private void AddFailureControlsInPanel(object sender) {
(sender as ASPxCallbackPanel).Controls.Add(new ASPxLabel() {
ID = "SuccessLabel",
Text = "Congratulations! You've passed the robot test!",
ForeColor = Color.Green
});
}
private void AddSuccessControlsInPanel(object sender) {
(sender as ASPxCallbackPanel).Controls.Add(new ASPxLabel() {
ID = "FailLabel",
Text = "You're a robot! To try again, please reload the page.",
ForeColor = Color.Red
});
}
}
Imports DevExpress.Web
Imports System.Drawing
Imports System.Web.UI
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub ResultsCallbackPanel_Callback(ByVal sender As Object, ByVal e As DevExpress.Web.CallbackEventArgsBase)
If CBool(CaptchaRadioButtonList.Value) Then
AddSuccessControlsInPanel()
Else
AddFailureControlsInPanel()
End If
End Sub
Private Sub AddFailureControlsInPanel()
ResultsCallbackPanel.Controls.Add(New ASPxLabel() With {.Text = "Congratulations! You've passed the robot test!", .ForeColor = Color.Green})
End Sub
Private Sub AddSuccessControlsInPanel()
ResultsCallbackPanel.Controls.Add(New ASPxLabel() With {.Text = "You're robot! To try again please reload the page.", .ForeColor = Color.Red})
End Sub
End Class
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v14.2, Version=14.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script>
function SubmitRobotTest(s, e) {
resultsPanel.PerformCallback();
};
function HideCaptchaList(s, e) {
captchaLabel.SetVisible(false);
captchaList.SetVisible(false);
};
</script>
</head>
<body>
<form id="form1" runat="server">
<dx:ASPxLabel ID="CaptchaLabel" runat="server"
ClientInstanceName="captchaLabel"
Text="Are you a robot? You have only one attempt!"
Width="200px">
</dx:ASPxLabel>
<dx:ASPxRadioButtonList ID="CaptchaRadioButtonList" runat="server"
ClientInstanceName="captchaList"
ValueType="System.Boolean"
SelectedIndex="0">
<Items>
<dx:ListEditItem Text="Yes" Value="true" />
<dx:ListEditItem Text="No" Value="false" />
</Items>
</dx:ASPxRadioButtonList>
<dx:ASPxButton ID="SubmitButton" runat="server" Text="Submit" AutoPostBack="false">
<ClientSideEvents Click="SubmitRobotTest" />
</dx:ASPxButton>
<dx:ASPxCallbackPanel ID="ResultsCallbackPanel" runat="server"
ClientInstanceName="resultsPanel"
Width="200px"
OnCallback="ResultsCallbackPanel_Callback">
<ClientSideEvents EndCallback="HideCaptchaList" />
</dx:ASPxCallbackPanel>
</form>
</body>
</html>
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Controls property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
xaf-how-to-create-information-panels/CS/InfoPanels.Web/MyDefaultVerticalTemplateContent.ascx.cs#L33
bool isVisible = false;
foreach (Control control in TRP.Controls) {
if (control is ActionContainerHolder) {
xaf-how-to-create-information-panels/VB/InfoPanels.Web/MyDefaultVerticalTemplateContent.ascx.vb#L35
Dim isVisible As Boolean = False
For Each control As Control In TRP.Controls
If TypeOf control Is ActionContainerHolder Then
See Also