0

I am working on iframes in ASP.NET. Below is the HTMlL code for iframe:

<iframe id="mainiFrame" name="mainiFrame" scrolling="auto" frameborder="2" 
            height="400px" width="500px"            
            src="" 
            runat="server"></iframe>

I am able to set the source of the iframe:

protected void Button1_Click(object sender, EventArgs e)
    {
        mainiFrame.Attributes["src"] = "http://roboticsindia.com";  
    }

How do i get the HTML source code from the iFrame?

Regards, Anil

4

3 回答 3

0

我不知道 iFrame 的 Html 源是否是属性,但是您可以这样做。

System.Net.WebClient wc = new System.Net.WebClient();
String s = wc.DownloadString(mainiFrame.Attributes["src"]);
于 2012-04-12T08:55:06.247 回答
0

如果页面“http://roboticsindia.com”不在您的项目中,您可以尝试使用 Webclient 来获取 HTML 内容...

于 2012-04-12T08:56:32.850 回答
0

我们可以设置 HTML I 框架属性如下。“testframe”是 I 框架的 id

this.testframe.Attributes["src"] = "http://examples.com";
于 2012-04-12T10:10:54.883 回答