user294636
user294636

Reputation: 121

setting height of asp:panel

I want to set the height of asp:panel to auto and I also want to ensure that max height is 400px and after that scroll bars must be present. I want to set it auto so that if the content is less than height 400px there will not be any empty space in the bottom. Any ideas?? :-)

Upvotes: 1

Views: 14027

Answers (2)

Heinzi
Heinzi

Reputation: 172220

I think the CSS max-height attribute should be most appropriate to what you want:

<style type="text/css">
    .myPanelClass { max-height: 400px; overflow: auto; }
</style>
<!--[if IE 6]>
    <style type="text/css">
        .myPanelClass { height: expression( this.scrollHeight > 399 ? "400px" : "auto" ); }
    </style>
<![endif]-->

<asp:Panel runat="server" CssClass="myPanelClass">
    ....
</asp:Panel>

(EDIT: added IE6 "support")

Upvotes: 9

Martin Milan
Martin Milan

Reputation: 6390

Though I prefer Heinzi's answer in general, if you really must use IE6, perhaps just forcing the height to 400px in CSS? Haven't tried it, but it might work.

Another strategy might be to use Javascript, but you're then relying on it being present.

Whoever is forcing you to use IE6, it would also be nice for them to get with the program...

Upvotes: 0

Related Questions