Redigera

Dela via


MenuItemStyle.HorizontalPadding Property

Definition

Gets or sets the amount of space to the left and right of the menu item's text.

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

Property Value

The amount of space (in pixels) to the left and right of the 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 HorizontalPadding property to pad the horizontal 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 HorizontalPadding Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItemStyle HorizontalPadding Example</h3>
      
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        runat="server">
        
        <staticmenuitemstyle horizontalpadding="10"
          backcolor="LightBlue"/>
        <dynamicmenuitemstyle horizontalpadding="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 HorizontalPadding Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>MenuItemStyle HorizontalPadding Example</h3>
      
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        runat="server">
        
        <staticmenuitemstyle horizontalpadding="10"
          backcolor="LightBlue"/>
        <dynamicmenuitemstyle horizontalpadding="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 HorizontalPadding property to control the amount of horizontal space around the text of the menu item to which the MenuItemStyle object is applied. This space is inserted between the left edge of the text and the border of the text area, and between the right edge of the text and the text's border. To control the vertical spacing, use the VerticalPadding property.

Applies to

See also