I have a panel in asp page and I want to add image to this panel so that this image is located at the center of the panel:
protected void Page_Load(object sender, EventArgs e)
{
Panel panel = new Panel();
panel.HorizontalAlign = HorizontalAlign.Center;
//here I want set verticalAlign for the panel
Image image = new Image();
image.imageURL = imageurl;
panel.controls.add(image);
this.form1.controls.add(panel);
}
I tried using CSS:
p.CssClass = "css1";
and css is:
<style type="text/css">
.css1
{
vertical-align: middle;
}
</style>
but this didn't give result.
So, how to locate image in center of the panel (horizontally and vertically)?
Please, do not recommend
padding-top:20px;
this changes the height of the panel. I must keep dimensions of panel constantly.