且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

动态地从页面后面的代码更改iFrame src

更新时间:2023-11-25 17:44:16



试试这个:

Hi,
Try this:
<iframe height="450px" width="450px" scrolling="auto" runat="server" id="iFrame1" />




protected void Page_Load(object sender, EventArgs e)
{
    string Url = "TXT/business applications_en.htm";
    //iFrame1.Attributes["src"] = Url;
    System.Web.UI.AttributeCollection aCol = iFrame1.Attributes;
    aCol.Add("src", "Test\test.aspx");
}









试试这个:添加一个隐藏的输入字段(使用runat =server属性)并将其值更改为JavaScript中的IFrame的src。这样,您就可以阅读该字段的值服务器端。



--Amit



OR

Try this: add a hidden input field (with runat="server" attribute) and change it's value to your IFrame's src in the JavaScript. That way, you'll be able to read the field's value server-side.

--Amit


ifrmMain.Attributes [src] =您的页面名称;
ifrmMain.Attributes["src"] = "Your page name";