.Net FindControl - find your html controls
Sometimes the FindControl method won't find your control, if its on the masterpage or if its inside a contentplace holder.
To fix this:
ContentPlaceHolder cph = this.Form.FindControl("ContentPlaceHolder1") as ContentPlaceHolder;
HtmlControl myFrame = (HtmlControl)cph.FindControl("iframe01");
myFrame.Attributes["src"] = url_geo;
or
HtmlControl myFrame = (HtmlControl)this.Master.FindControl("controlid");
Source:
http://csharporcas.blogspot.com/2006/05/master-page-find-control.html
P.S.: Your iframe may need the runat="server" tag for this to work!
To fix this:
ContentPlaceHolder cph = this.Form.FindControl("ContentPlaceHolder1") as ContentPlaceHolder;
HtmlControl myFrame = (HtmlControl)cph.FindControl("iframe01");
myFrame.Attributes["src"] = url_geo;
or
HtmlControl myFrame = (HtmlControl)this.Master.FindControl("controlid");
Source:
http://csharporcas.blogspot.com/2006/05/master-page-find-control.html
P.S.: Your iframe may need the runat="server" tag for this to work!
Comments
Post a Comment