Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Panel.Wrap Property

Gets or sets a value indicating whether the content wraps within the panel.

[Visual Basic]
Public Overridable Property Wrap As Boolean
[C#]
public virtual bool Wrap {get; set;}
[C++]
public: __property virtual bool get_Wrap();
public: __property virtual void set_Wrap(bool);
[JScript]
public function get Wrap() : Boolean;
public function set Wrap(Boolean);

Property Value

true if the content wraps within the panel; otherwise, false. The default is true.

Remarks

Use this property to wrap the contents of the Panel.

Example

[Visual Basic, C#] The following example illustrates how to programmatically set the Wrap property of the Panel control.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
 <head>
    <script language="VB" runat="server">
 
    Sub Page_Load(sender As Object, e As EventArgs)
       Dim l As New Label()
       l.Text = "This panel contains a label control."
       Panel1.Controls.Add(l)
    End Sub
    
    Sub Button1_Click(sender As Object, e As EventArgs)
       If Panel1.Wrap = True Then
          Panel1.Wrap = False
          Button1.Text = "Set Wrap=True"
       Else
          Panel1.Wrap = True
          Button1.Text = "Set Wrap=False"
       End If
    End Sub
 
    </script>
 </head>
 <body>
 
    <h3>Panel Example</h3>
    <form runat=server>
 
       <asp:Panel id="Panel1" Height=200 Width=100 BackColor="Gainsboro"
            Wrap="True" runat="server"/>
     
       <p> 
       <asp:Button id="Button1" OnClick="Button1_Click"
            Text="Set Wrap=False" runat="server"/>
 
    </form>
 </body>
 </html>
 

[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
 <head>
    <script language="C#" runat="server">
 
    void Page_Load(Object sender, EventArgs e) {
       Label l = new Label();
       l.Text = "This panel contains a label control.";
       Panel1.Controls.Add(l);
    }
     
    void Button1_Click(Object sender, EventArgs e) {
       if (Panel1.Wrap == true) {
          Panel1.Wrap = false;
          Button1.Text = "Set Wrap=True";
       } 
       else {
          Panel1.Wrap = true;
          Button1.Text = "Set Wrap=False";
       }
    }
 
    </script>
 </head>
 <body>
 
    <h3>Panel Example</h3>
    <form runat=server>
 
       <asp:Panel id="Panel1" Height=200 Width=100 BackColor="Gainsboro"
            Wrap="True" runat="server"/>
     
       <p> 
       <asp:Button id="Button1" OnClick="Button1_Click"
            Text="Set Wrap=False" runat="server"/>
 
    </form>
 </body>
 </html>
 

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

Panel Class | Panel Members | System.Web.UI.WebControls Namespace

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.