Friday, July 16, 2010

iFrame in an ASP.NET page

iFrame controls are standard HTML controls and are not available as an ASP.NET object in the code behind file. If you want to access this object the only way to do that is to find the control and set the attributes of the control manually For example if the control is named myIFrame in the HTML file in a code-behind event handler we can get a hold on the control by calling
 HtmlControl myCodeBehindAcceddToIFrame = (HtmlContrl)this.FindControl(myIFrame); 
To set one of its attributes we can make a call similar to
 myCodeBehindAcceddToIFrame.Attributes["src"] = "…new url..." 

No comments:

Post a Comment