Thursday, 30 May 2013

Remove .net styling from GridView

Don't you just hate the way .net webforms insists on adding style and border attributes to the tables produced by Gridviews and other controls? Well I came up with a pretty reliable way of getting rid of them so my css (specified in the 'CssClass' attribute of the gridview) can take over.
$(document).ready(function () {
    $('table').filter(function (index) {
        $(this).removeAttr("style");
        $(this).removeAttr("rules");
        $(this).removeAttr("border");
        $(this).removeAttr("cellspacing");
        $(this).removeAttr("cellpadding");
    });
});

No comments:

Post a Comment

Comments are moderated, so you'll have to wait a little bit before they appear!