I am trying to set attributes for an IFRAME html control from the code-behind aspx.cs file.
I came across a post that says you can use FindControl to find the non-as
Try this.
ContentPlaceHolder cplHolder = (ContentPlaceHolder)this.CurrentMaster.FindControl("contentMain");
HtmlControl cpanel= (HtmlControl)cplHolder.FindControl("contentPanel1");
If the iframe is directly on the page where the code is running, you should be able to reference it directly:
contentPanel1.Attribute = value;
If not (it's in a child control, or the MasterPage), you'll need a good idea of the hierarchy of the page... Or use the brute-force method of writing a recursive version of FindControl().
aspx page
<iframe id="fblikes" runat="server"></iframe>
Code behind
this.fblikes.Attributes["src"] = "/productdetails/fblike.ashx";
Very simple....
This works for me.
ASPX :
<iframe id="ContentIframe" runat="server"></iframe>
I can access the iframe directly via id.
Code Behind :
ContentIframe.Attributes["src"] = "stackoverflow.com";