System.Web.UI Namespace Control Class
Sets or retrieves a value specifying whether a control should be rendered on the page.
Inline |
<asp:control Visible = true | false ... > |
Script |
Control.Visible = true | false |
This property accepts or returns only a boolean value: true if the control is to be rendered; otherwise false.
If this property is false, the server control is not rendered. Authors
should take this into account when organizing the lay out of the page.
The following example shows how to declaratively set the Visible property of a control at design time.
<asp:panel id="myPanel" runat="server" visible=false>
The example below shows how to alternately show or hide a control by programmatically setting its Visible property at run time. The sample also demonstrates how the state of the Visible property can be used to conditionally modify the property of another control or render additional content on the page.
void ShowHide ( object src, EventArgs E ) {
thePanel.Visible = thePanel.Visible ? false : true;
myButton.Text = thePanel.Visible ? "Hide me" : "Show me";
}
Sub ShowHide ( src As Object, E As EventArgs )
thePanel.Visible = Iif ( thePanel.Visible, False, True )
myButton.Text = Iif ( thePanel.Visible, "Hide me", "Show me" )
End Sub |
|
C# |
VB |
Show me
The example below shows how to programmatically set the Visible property at run time, depending on the state of another control.
myGrid.PagerStyle.Visible = showPager.Checked;
myGrid.PagerStyle.Visible = showPager.Checked |
|
C# |
VB |
Show me
Control Members