How do you set the min-height of an iframe from c# code-behind?
HtmlGenericControl iframectrl = new HtmlGenericControl("iframe");
iframectrl.Attributes.Add("src","blah blah blah");
iframectrl.Attributes.Add("width","10开发者_JAVA技巧0%");
iframectrl.Attributes.Add("min-height", "100%");
I am creating an iframe dynamically (as seen above) and putting it on a tab panel which is also created dynamically. I can set the height of the tab container and the tab panel from my PageLoad function, but I cannot get the height of the iframe to set correctly no matter what I do. I am trying to avoid using Javascript to set the height. I have tried adding an attribute for this, but it doesn't work. If I create the iframe control in my aspx page, I can set min-height and it works fine. Should I create my iframe in a PreLoad or PreRender function or is there something better?
Try adding as a CSS style.
iframectrl.Attributes.Add("style", "min-height:100%,width:100%;");
精彩评论