Setting ASP.NET update panel to be 100% of its parent container?
How can I set an ASP开发者_JAVA百科.NET update panel to be 100% of its parent container? Right now it's height is just big enough to fit its contents. It's display mode is block. I added a
style="height: 100%"
attribute to the updatepanel tag, but the parser complained that the style tag is undefined for asp:UpdatePanel
.
Try putting the asp:UpdatePanel
inside of a asp:Panel
and use that to control the size.
height: 100%
is very bad style solution. This won't work after resizing or similar user actions.
All you can do - set the height automatically by javascript. See also this answer (it is about the iframe, but javascript is easily updated for your needs)
It's a little hacky but you could do something like this to style an UpdatePanel
<head>
...
<style type="text/css">
#<%=UpdatePanel1.ClientID %> {height:100%;}
</style>
...
</head>
<body>
...
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
...
</asp:UpdatePanel>
You can use C# backend to control style of update panel in at the page_load.
protected void Page_Load(object sender, EventArgs e)
{
UpdatePanel.Attributes.CssStyle.Add("height","100%");
}
精彩评论