code_junkie

How can I access an IFRAME from the codebehind file in ASP.NET?

Nov 11th, 2011
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <iframe id="contentPanel1" runat="server" />
  2.  
  3. protected void Page_Load(object sender, EventArgs e)
  4. {
  5. HtmlControl contentPanel1 = (HtmlControl)this.FindControl("contentPanel1");
  6. if (contentPanel1 != null)
  7. contentPanel1.Attributes["src"] = "http://www.stackoverflow.com";
  8.  
  9. }
  10.  
  11. <iframe id="ctl00_ContentPlaceHolder1_contentPanel1"></iframe>
  12.  
  13. HtmlControl contentPanel1 = (HtmlControl)this.FindControl("ctl00_ContentPlaceHolder1_contentPanel1");
  14.  
  15. if (contentPanel1 != null)
  16. contentPanel1.Attributes["src"] = "http://www.clis.com";
  17.  
  18. <iframe id="contentPanel1" name="contentPanel1" runat="server" />
  19.  
  20. <iframe id="contentPanel1" runat="server" />
  21.  
  22. this.contentPanel1.Attributes["src"] = "http://www.stackoverflow.com";
  23.  
  24. contentPanel1.Attribute = value;
  25.  
  26. protected virtual Control FindControlRecursive(Control root, String id)
  27. {
  28. if (root.ID == id) { return root; }
  29. foreach (Control c in root.Controls)
  30. {
  31. Control t = FindControlRecursive(c, id);
  32. if (t != null)
  33. {
  34. return t;
  35. }
  36. }
  37. return null;
  38. }
Add Comment
Please, Sign In to add comment