Editar

Partilhar via


MenuItemStyle.VerticalPadding Property

Definition

Gets or sets the amount of space above and below a menu item's text.

public:
 property System::Web::UI::WebControls::Unit VerticalPadding { System::Web::UI::WebControls::Unit get(); void set(System::Web::UI::WebControls::Unit value); };
public System.Web.UI.WebControls.Unit VerticalPadding { get; set; }
member this.VerticalPadding : System.Web.UI.WebControls.Unit with get, set
Public Property VerticalPadding As Unit

Property Value

The amount of space (in pixels) above and below a menu item's text. The default is 0.

Exceptions

The selected value is of type Percentage.

-or-

The selected value is less than 0.

Examples

The following code example demonstrates how to use the VerticalPadding property to pad the vertical spacing around the text of a menu item by 10 pixels.


<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>MenuItemStyle VerticalPadding Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItemStyle VerticalPadding Example</h3>
      
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        runat="server">
        
        <staticmenuitemstyle verticalpadding="10"
          backcolor="LightBlue"/>
        <dynamicmenuitemstyle verticalpadding="10"
          backcolor="LightBlue"/>
      
        <items>
          <asp:menuitem text="Home"
            tooltip="Home">
            <asp:menuitem text="Music"
              tooltip="Music">
              <asp:menuitem text="Classical"
                tooltip="Classical"/>
              <asp:menuitem text="Rock"
                tooltip="Rock"/>
              <asp:menuitem text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem text="Movies"
              tooltip="Movies">
              <asp:menuitem text="Action"
                tooltip="Action"/>
              <asp:menuitem text="Drama"
                tooltip="Drama"/>
              <asp:menuitem text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>
      
      </asp:menu>

    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>MenuItemStyle VerticalPadding Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItemStyle VerticalPadding Example</h3>
      
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        runat="server">
        
        <staticmenuitemstyle verticalpadding="10"
          backcolor="LightBlue"/>
        <dynamicmenuitemstyle verticalpadding="10"
          backcolor="LightBlue"/>
      
        <items>
          <asp:menuitem text="Home"
            tooltip="Home">
            <asp:menuitem text="Music"
              tooltip="Music">
              <asp:menuitem text="Classical"
                tooltip="Classical"/>
              <asp:menuitem text="Rock"
                tooltip="Rock"/>
              <asp:menuitem text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem text="Movies"
              tooltip="Movies">
              <asp:menuitem text="Action"
                tooltip="Action"/>
              <asp:menuitem text="Drama"
                tooltip="Drama"/>
              <asp:menuitem text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>
      
      </asp:menu>

    </form>
  </body>
</html>

Remarks

Use the VerticalPadding property to control the amount of vertical space around the text of the menu item to which the MenuItemStyle object is applied. This space is inserted between the upper edge of the text and the border of the text area, as well as between the lower edge of the text and the text's border. To control the horizontal spacing, use the HorizontalPadding property.

Applies to

See also