No Page_Load event when loading .aspx page into iframe

G

Guest

Hello,

I am working on an ASP .NET application in Visual Studio 2005 and running
IE7.

This application has a page that contains an iframe which loads an .aspx
page and hyperlinks that load the iframe with different .aspx pages. The
HTML/mark up for the .aspx pages executes every time, but the Page_Load
events for the pages never run (on initial load or subsequent loads).

All of my research so far indicates that the page_load event should occur
and I have seen a version of this application (developed in framework 1.1)
work on another server which was running IE6. Is there a difference here with
previous versions of ASP .NET or IE that anyone knows about?

I have developed a very simple set of test pages that recreate the problem,
and am including the code below.

Thank you in advance for any help!

-----------------------------------
Page with IFRAME:

<%@ Page Language="vb" Codebehind="test_iframe_page.aspx.vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>test_iframe_page</title>
</HEAD>
<body >
<form id="test_iframe_page" name="test_iframe_page" method="post"
runat="server">
<p>This is the test_iframe_page</p>
<A href="test_page2.aspx" target="iframe"><b>REFRESH IFRAME WITH
TEST PAGE 2</b></A>
<br /><br />
<A href="test_page.aspx" target="iframe"><b>REFRESH IFRAME WITH
TEST PAGE 1</b></A>
<br /><br />
<TABLE cellSpacing="0" cellPadding="0" width="100%" align="center"
border="0" height="100%">
<tr>
<td align="center" width="100%">
<iframe id="iframe1" name="iframe" marginWidth="0" marginHeight="0"
src="test_page.aspx"
frameBorder="yes" width="100%" scrolling="auto" height="100%">
</iframe>
</td>
</tr>
</TABLE>
</form>
</body>

</HTML>

Load pages:

<%@ Page Language="vb" Codebehind="test_page.aspx.vb" %>
<HTML>
<HEAD>
<title>test_page</title>
</HEAD>
<body>
<form id="Form1">
<p>Hello world this is test_page!</p>
</form>
</body>
</HTML>

<%@ Page Language="vb" Codebehind="test_page.aspx.vb" %>
<HTML>
<HEAD>
<title>test_page2</title>
</HEAD>
<body>
<form id="Form1">
<p>Hello world this is test_page2!</p>
</form>
</body>
</HTML>
 
I

IfThenElse

So you put a break point in the page_load event handler and you are in debug
mode not release mode and still can not get a hit on the break point?
 
G

Guest

Thank you for your reply.

Yes - that is correct. And I also put in a response.write() statement in
the page_load event as well, just in case the breakpoint wasn't working for
some reason!
 
B

bruce barker

the browser will cache the pages so request is made. set the caching
policy on the pages.

-- bruce (sqlwork.com)
 
G

Guest

Thanks for the suggestion.

I tried disabling caching on the main page with the iframe as well as the
two test pages, but this had no effect. I am still not getting the page_load
event.

I disabled caching in two ways on the pages, by adding this statement under
the page directive:
<%@ OutputCache Location="None" %>

and by adding these statements to the <head> area:
<meta http-equiv="Expires" content="0">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
 
G

Guest

Thanks for all your help but I finally stumbled on a solution - I have no
idea why it works though!

In the page directive for the pages that are being loaded into the iframe, I
replaced

Codebehind="test_page.aspx.vb"

with

CodeFile="test_page.aspx.vb" Inherits="test_page"

Hope this helps someone else!
 
I

IfThenElse

see this link http://www.ddj.com/windows/187202007


CodeFile is for stock projects and CodeBehind for WAP and it affects how
ASP.NET compiles the page as you probably know.
The issue with CodeFile is that the code is compiled into it's own (or
directory level assembly) and so the type may not be available to another
page unless the control is @Registered. If you dynamically load you pretty
much can't reference the ASCX codebehind class.

With WAP everything goes into a single assembly so you can reference the
codebehind class from just about anywhere...

The thing is that if you forget to set the proper format for WAP code the
page/control will still work because ASP.NET internally doesn't care whether
a project is stock or WAP so the page/control runs just fine with CodeFile.



CodeFile is used for the Web Site project type that shipped with VS.Net
2005. The Web Application Project changed this back to the original
CodeBehind used in VS 2002 and 2003 Web Application Projects.

the migration tool for going from Web Site to WAP doesn't make this change
for you, unfortunately. Hence these lingering issues.
 
G

Guest

Thank you for your help. I appreciate all of the quick replies - and will
use this forum again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top