JQuery: Positioning a GridView control in centre of page for Chrome browser

A  Gridview control renders as a <table> surrounded by a <div> element.

Setting the  GridView control property ‘HorizontalAlign’ to ‘Center’ does not appear to work in Chrome.

Rather than create a new parent div with align=”centre” around the GridView you just need to use jQuery to position the rendered GridView table relative to the generated div.

If the GridView control property CSSClass=”mGrid” then the following works:

$(“.mGrid”).position({
my: “center”,
at: “center”,
of: $(“.mGrid”).parent()
});

For further information on the position method visit https://api.jqueryui.com/position/.

Advertisements