【问题标题】:How do you set the min-height of an iframe from c# code-behind?如何从 c# 代码隐藏设置 iframe 的最小高度?
【发布时间】:2011-09-15 01:24:06
【问题描述】:
    HtmlGenericControl iframectrl = new HtmlGenericControl("iframe");
    iframectrl.Attributes.Add("src","blah blah blah");
    iframectrl.Attributes.Add("width","100%");
    iframectrl.Attributes.Add("min-height", "100%");

我正在动态创建一个 iframe(如上所示)并将它放在一个标签面板上,该面板也是动态创建的。我可以从我的 PageLoad 函数设置选项卡容器和选项卡面板的高度,但无论我做什么,我都无法正确设置 iframe 的高度。我试图避免使用 Javascript 来设置高度。我已经尝试为此添加一个属性,但它不起作用。如果我在我的 aspx 页面中创建 iframe 控件,我可以设置 min-height 并且它工作正常。我应该在 PreLoad 或 PreRender 函数中创建 iframe,还是有更好的方法?

【问题讨论】:

    标签: asp.net iframe height code-behind css


    【解决方案1】:

    尝试添加为 CSS 样式。

    iframectrl.Attributes.Add("style", "min-height:100%,width:100%;");
    

    【讨论】:

      猜你喜欢
      • 2011-03-21
      • 1970-01-01
      • 1970-01-01
      • 2019-11-03
      • 2016-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-10
      相关资源
      最近更新 更多