Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1230
Webdatagrid runtime change CSS
posted

How can one change Webdatagrid css at runtime? In my case I had placed  Webdatagrid inside UserControl and used this UserControl on multiple page. Now I want that if page1 is clicked, then say red border and some other attributes are displayed for grid and if say page 2 is clicked, then say white border, etc.

Parents
No Data
Reply
  • 1230
    Verified Answer
    posted

    One can do it either in codebehind or using jquery.

    Inside UserControl, changed css of Webdatagrid like below:

    <script type="text/javascript">
        $(document).ready(function () { 
            if ($("input[id$=hfIsTab]").val() == null)  // Hidden Field defined in Master page
                $('.igg_Header').css("background-color", "#efe092");  //Tab Page
            else
                $('.igg_Header').css("background-color", "#fff");  //Main Page
        });
    </script>

    In general, one can also do it like below:

    $('.class').css("color",((Variable > 0) ? "#009933":"#000"));



Children
No Data