• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 352
  • Last Modified:

alignment for a listview in firefox and IE

Hi,
  I have shown the code below.
  How would I align it to the center of the page in both firefox and IE.
Thanks, LLJ45
<asp:ListView ID="lvLetter" runat="server" ItemPlaceholderID="itemPlaceholder">
                <LayoutTemplate>
                    <table>
                        <td id="itemPlaceholder" runat="server">
                        </td>
                    </table>
                </LayoutTemplate>
                
                <ItemTemplate>
                    <asp:LinkButton ID="lnkLetter" runat="server" Text='<%#Eval("letter")%>'
                        CommandName="Find" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Letter") %>'>
                    </asp:LinkButton>
                </ItemTemplate>
            </asp:ListView>

Open in new window

0
llj45
Asked:
llj45
  • 2
  • 2
  • 2
  • +1
1 Solution
 
informaniacCommented:
Place an enclosing div around the listview and provide an id to it.

OnLoad of the Body write a javascript function.

In js find the Height and Width of the body divide it by two.

Set the position of div to this value...
0
 
bklmnshCommented:
I believe the solution above is incomplete
I think it should be something like following:

div.top = body.height / 2 - div.height / 2
div.left = body.width / 2 - div.widht / 2
0
 
masterpassCommented:
after the body put a center tag

<body>
<center>
ListView here
</center>
</body>
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
llj45Author Commented:
Hi,
  Thanks for the help!
  The listview still does NOT center on the page!

  I have attached the updated code.
Thanks, LLJ45
<script type="text/javascript" language="javascript">
            function center()
            {
                control.top = body.height / 2 - div.height / 2
                control.left = body.width / 2 - div.width / 2
            }
        </script>

    <body onload="center();">

            <div id="control">
            <asp:ListView ID="lvLetter" runat="server" ItemPlaceholderID="itemPlaceholder">
                <LayoutTemplate>
                    <table>
                        <td id="itemPlaceholder" runat="server">
                        </td>
                    </table>
                </LayoutTemplate>
                
                <ItemTemplate>
                    <asp:LinkButton ID="lnkLetter" runat="server" Text='<%#Eval("letter")%>'
                        CommandName="Find" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Letter") %>'>
                    </asp:LinkButton>
                </ItemTemplate>
            </asp:ListView>
            </div>

Open in new window

0
 
masterpassCommented:
Try this
<body>
<center>
            <div id="control">
            <asp:ListView ID="lvLetter" runat="server" ItemPlaceholderID="itemPlaceholder">
                <LayoutTemplate>
                    <table>
                        <td id="itemPlaceholder" runat="server">
                        </td>
                    </table>
                </LayoutTemplate>
                
                <ItemTemplate>
                    <asp:LinkButton ID="lnkLetter" runat="server" Text='<%#Eval("letter")%>'
                        CommandName="Find" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Letter") %>'>
                    </asp:LinkButton>
                </ItemTemplate>
            </asp:ListView>
            </div>
</center>
</body>

Open in new window

0
 
bklmnshCommented:
var control = document.getElementById("control");
control.top = document.body.clientHeigth / 2 - control.height / 2
control.left = document.body.clientWidth / 2 - control.width / 2
0
 
llj45Author Commented:
THANKS!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now