I have an asp.net website with a master-page, can I use the iframe
so my .aspx
pages will load inside the iframes
. (Meaning it wont load the master-page)
Kinda like my iframe
will be the contentplaceholder
or maybe the contentplaceholder
will be inside it?
Any Ideas?
The <iframe> tag specifies an inline frame. An inline frame is used to embed another document within the current HTML document.
<iframe> is not an obsolete or deprecated tag. It's still widelly used in the web, mostly for media purposes.
You can put an iframe in any HTML page, so you could put one inside a contentplaceholder in a webform that has a Masterpage and it will appear with whatever URL you load into it (via Javascript, or C# if you turn your iframe into a server-side control ( runat='server' ) on the final HTML page that your webform produces ...
Google Says Do Not Use iFrames In fact, even Google says, don't do it – straight from its developer site: “We recommend that you avoid the use of iFrames to display content.”
try this
<iframe name="myIframe" id="myIframe" width="400px" height="400px" runat="server"></iframe>
Expose this iframe in the master page's codebehind:
public HtmlControl iframe { get { return this.myIframe; } }
Add the MasterType directive for the content page to strongly typed Master Page.
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits=_Default" Title="Untitled Page" %> <%@ MasterType VirtualPath="~/MasterPage.master" %>
In code behind
protected void Page_Load(object sender, EventArgs e) { this.Master.iframe.Attributes.Add("src", "some.aspx"); }
Another option is to use placeholders.
Html:
<body> <div id="root"> <asp:PlaceHolder ID="iframeDiv" runat="server"/> </div> </body>
C#:
iframeDiv.Controls.Add(new LiteralControl("<iframe src=\"" + whatever.com + "\"></iframe><br />"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With