I'm trying to use an <iframe>
to point to an .aspx
file, but when I load it I keep getting an empty frame, no matter what is in the target .aspx
nothing gets displayed. Here the html:
<html xmlns="" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
This is the principal page</div>
<iframe id="myIframe" src="SimpleTarget.aspx" height="100%" width="100%"></iframe>
</form>
</body>
</html>
Then I tried it pointing to an html and it was succesfully rendered in the browser showing the html content. Here the html:
<html xmlns="" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
This is the principal page</div>
<iframe id="myIframe" src="HTMLPage1.htm" height="100%" width="100%"></iframe>
</form>
</body>
</html>
So my question is, am I missing something when defining the iframe
or is pletely impossible to point to an .aspx
with an iframe
?
In case it is impossible, is there another way to show aspx pages within another html page?
I'm trying to use an <iframe>
to point to an .aspx
file, but when I load it I keep getting an empty frame, no matter what is in the target .aspx
nothing gets displayed. Here the html:
<html xmlns="http://www.w3/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
This is the principal page</div>
<iframe id="myIframe" src="SimpleTarget.aspx" height="100%" width="100%"></iframe>
</form>
</body>
</html>
Then I tried it pointing to an html and it was succesfully rendered in the browser showing the html content. Here the html:
<html xmlns="http://www.w3/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
This is the principal page</div>
<iframe id="myIframe" src="HTMLPage1.htm" height="100%" width="100%"></iframe>
</form>
</body>
</html>
So my question is, am I missing something when defining the iframe
or is pletely impossible to point to an .aspx
with an iframe
?
In case it is impossible, is there another way to show aspx pages within another html page?
Share Improve this question edited Oct 19, 2012 at 8:59 nalply 28.8k15 gold badges82 silver badges104 bronze badges asked Feb 22, 2010 at 18:23 Carlos CastilloCarlos Castillo 5532 gold badges6 silver badges12 bronze badges 3- 2 Yes, it's possible . . . . Have you first tried to see if your .aspx page loads properly outside the iFrame? – Tim Goodman Commented Feb 22, 2010 at 18:26
- What you have should work assuming your aspx page works properly. Post the aspx page code. – Aaron Commented Feb 22, 2010 at 18:27
- What are the full paths of the pages? – SLaks Commented Feb 22, 2010 at 18:27
5 Answers
Reset to default 4It should work with SimpleTarget.aspx just make sure that the relative path is correct and the page is loaded when you hit it with the browser ...
Is this bit a typo? if not it could be your problem
src="SimpleTarget.aspx"height="100%"
should be
src="SimpleTarget.aspx" height="100%"
This is also a typo (but would not break your rendering.
<iframe id="myIframe" src="HTMLPage1.htm" 100%" width="100%">
should be
<iframe id="myIframe" src="HTMLPage1.htm" height="100%" width="100%">
A request for an .aspx page is no different from a request for an HTML file. Either your asp page is not rendering properly (possibly a server error?) or else your iframe is not pointing to it correctly.
I do notice that you have a badly formatted src tag for the .aspx page..
src="SimpleTarget.aspx"height="100%"
should be
src="SimpleTarget.aspx" height="100%"
I found that the following in a Global.asax file stopped iframes opening aspx pages:
void Application_BeginRequest(object sender, EventArgs e) {
HttpContext.Current.Response.AddHeader("X-Frame-Options", "DENY");
}
Used to stop cross site scripting but also breaks internal iframes when using aspx pages; removing this "fixed" the problem for me.
In firefox you can right click in th iframe and get an iframe menu and choose to open the frame in a new tab - this will confirm the actual url being used by the browser for the iframe and as others have stated allow you to ensure the aspx page does render correctly.