Link to home
Start Free TrialLog in
Avatar of GlobaLevel
GlobaLevelFlag for United States of America

asked on

Asp.NET - Center web page

Any way to center the web page, instead of it attached to the upper left corner? Also, to have a background image on left margin and right margin...
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>



<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Menu Behaviors</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <h2>Menu Behaviors Sample</h2>
    This sample demonstrates the Menu in the horizontal orientation using a
    StaticFormatString and a StaticPopOutImage. Menu items
    that are constantly on display contain the prefix <b>Read</b>
    before their title. Static menu items that contain
      child items also display an image to indicate that there is pop-up functionality.<br /><br />
        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" 
         StaticPopOutImageUrl="images/separator1.gif">
            <Items>
                <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Login" 
                  Value="Book 0"/>
                <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Book 1" 
                  Value="Book 1">
                    <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Chapter 0" 
                      Value="Chapter 0"/>
                    <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Chapter 1" 
                      Value="Chapter 1">
                        <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Page 1" 
                          Value="Page 1"/>
                    </asp:MenuItem>
                </asp:MenuItem>
                <asp:MenuItem Text="Book 2" Value="Book 2">
                    <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Chapter 0" 
                      Value="Chapter 0"/>
                    <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Chapter 1" 
                      Value="Chapter 1">
                        <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Page 1" 
                          Value="Page 1"/>
                    </asp:MenuItem>
                    <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Chapter 2" 
                      Value="Chapter 2">
                        <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Page 1" 
                          Value="Page 1"/>
                        <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Page 2" 
                          Value="Page 2"/>
                    </asp:MenuItem>
                </asp:MenuItem>
                <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Book 3" 
                  Value="Book 3">
                    <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Chapter 0" 
                      Value="Chapter 0"/>
                    <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Chapter 1" 
                      Value="Chapter 1">
                         <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Page 1" 
                         Value="Page 1"/>
                     </asp:MenuItem>    
                    <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Chapter 2" 
                      Value="Chapter 2">
                         <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Page 1" 
                          Value="Page 1"/>
                         <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Page 2" 
                          Value="Page 2"/>
                    </asp:MenuItem>
                    <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Chapter 3" 
                      Value="Chapter 3">
                         <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Page 1" 
                          Value="Page 1"/>
                         <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Page 2" 
                          Value="Page 2"/>
                         <asp:MenuItem NavigateUrl="~/MenuBehaviors_cs.aspx" Text="Page 3" 
                          Value="Page 3"/>
                    </asp:MenuItem>
                 </asp:MenuItem>
            </Items>
            <StaticMenuItemStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="2px"
               HorizontalPadding="10px" />
        </asp:Menu>
        <br />
        <br />
        <br />
        <br />
        <b>Sample Note: </b>All menu items in this example point to the same page.
        </div>
        <br />
        <br />
    &nbsp;
</form>
</body>
</html>

Open in new window

Avatar of kaufmed
kaufmed
Flag of United States of America image

Using CSS, set a width on your BODY and set its margins to auto:
body{
    width: 768px;
    margin: auto;
}

Open in new window

    <div align="center">    <h2>Menu Behaviors Sample</h2>


ASKER CERTIFIED SOLUTION
Avatar of Greg Gamble
Greg Gamble
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial