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?? :-)
+3
A:
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")
Heinzi
2010-04-06 07:33:05
+1 Be aware that `max-height` is unsupported in IE6, though.
Jørn Schou-Rode
2010-04-06 07:40:43
Hi I tried your sugesstion but still panel height grows with the content
2010-04-06 07:41:34
Any other sugesstions?
2010-04-06 07:55:56
I am working with IE6 is there any way to set max-height in IE6?
2010-04-06 07:57:38
@gowri: I've added something that should work with IE6 (according to various Internet sources), but I cannot test it since I don't have IE6 around here anymore...
Heinzi
2010-04-06 08:12:57
I have tested that :-)Its working :-)Thanks :-)
2010-04-06 09:55:49
A:
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...
Martin Milan
2010-04-06 08:07:55