An array of C#, PHP, and HTML programming articles, tutorials, and resources

Posts Tagged ‘ programmatically ’

To programmatically setup and use an iframe in C#, copy the below iframe code snippet into your aspx page. You are free to add or edit any of the iframe attributes below, but note that the id and the runat attributes are required!

<iframe id="myIframe" runat="server" scrolling="auto">
</iframe >

Now in the aspx page’s codebehind, you can access the control as myIframe. To set a new URL in the iframe during postback, use the below snippet. The example below will dynamically load http://www.victorchen.info in the iframe window.

myIframe.Attributes["src"] = http://www.victorchen.info

You now you have a working iframe in your C# code and accessible in your codebehind.