Sunday, March 11, 2012

Applying css class to an UpdatePanel

Use a wrapper div.
Could do, but thats a nasty hack where we should be able to put a css class on the update panel. I guess I was more hoping for an obvious feature to be added in the next release.

I can't see how that would help in this situation (though my css isn't amazing). I would end up with:

<div class="displaymeinline">
<div id="updatepanel12345">
<div class="contentclass">
...

And that's starting to get a little ridiculous where a single class attribute on the update panel would do the job of all three divs. The inner div only exists because I can't put a class attribute on the update panel in the first place.

A.
I'm not saying it's the best way, just that you're choices now are to do as above, or don't do it at all.
Maybe - settings css by control id is the current hack (with a list of about 20 update panel ids all saying the same thing). But that, and the wrapper div, still doesn't really help as you can't then change the css class during an async postback.

Have you ever tried inheriting from the update panel? Would that allow it to be done do you think?

A.
I've not tried, but I'd expect it to work. Go for it.

Try:

#UpdatePanel1 {

}

in your CSS


The original problem with this still applies though: "Doing it by ID is not ideal due to the way that IDs change in content pages within master pages."

I had a custom update panel which I put the css class into, it didn't work in all situations. Nikhil Kothari now has astyled update panel that can be used.

Andy

No comments:

Post a Comment