Search code examples
jqueryasp.netcheckboxlistautopostback

J-query-Styles disappear on ListItems of checkboxlist when autopostback is set to true


I am using jquery to style the checkboxlist, the problem is, jquery styles the check box list , but when the listitem is pressed , the style is lost, I guess it is due to autopostback=true, I cant disable it coz i want to call postback to populate the datalist depending on the selected checked item, is there any alternative or any suggestions .

I am using http://www.no-margin-for-errors.com/projects/prettycheckboxes/ to style the checkboxlist


Solution

  • Sounds to me like you're styling the page in something like $(document).ready(...); The problem with that is that it only executes once when the page loads initially. But if anything is loaded asynchronously, it will lose dynamic style. So you have at least two options:

    1. Factor out the code that styles your checkboxes. Hook it into the event that gets raised when the auto-postback is done.
    2. Apply the styles statically to the checkboxes themselves using css. jQuery styles do nothing but to add css classes. You can do the same thing in your html, just inspect the elements in a web development tool and find out how exactly they're styled.