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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s