Asp.net and Frames

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

how can I reference frame objects to a .net object

meaning how can I search for the frame and do things to that frame object
 
give the runat="server" attribute to the frame. and you can declare it in
your codebehind like :
protected System.Web.UI.HtmlControls.HtmlGenericControl ifrm;



if you want to access-change attributes of iframe(or frame), use
ifrm.Attributes["src"] = "www.google.com"; notation. if you want to add
attribute, use ifrm.Attributes.Add("src", "www.google.com"); notation. you
can also access its child controls with Controls property. note that you can
change the inner text or innerhtml of frame also with code.. hope this helps
 
<iframe id="ifrm" runat="server" />

protected System.Web.UI.HtmlControls.HtmlGenericControl ifrm;

if(DateTime.Now.Month > 6)
{
ifrm.Attributes["src"] = "www.google.com";
}
else
{
ifrm.Attributes["src"] = "www.yahoo.com";
}

:)
 
Back
Top