No Page_Load event when aspx is in iFrame?

S

Stevie_mac

It might be me but...

I dont seem to get a Page_Load event when a opening an ASPX in an iFrame. I
do geta Page_Load event when an item on the ASPX (inside the iFrame) is
clicked but then IsPostBack=False by now!. The ASPX is opened via client
side script (into an iFrame) inside a .HTM file (as ASPX postback causes
problems in a modal internet explorer dialog if not in an iFrame!)

Anyone know how to get around this - i need to examine querystring variables
on 1st load!

Current setup...
MAIN.aspx - contains a link (to popup.htm), it contains client script...
window.showModalDialog('popup.htm','popup.aspx?v1=" &
txtStartDate.Text &
"','status:no;dialogWidth:250px;dialogHeight:250px;dialogHide:true;help:no;s
croll:no')

in 'popup.htm' - client script sets the src to the 2nd arg
('popup.aspx?v1='???') supplied in showModalDialog
<script language='javascript'>
//<!--
function load()
{
var src = window.dialogArguments;
if (src) {
document.all.Frame1.src = src;
}
}
//-->
</script>
 
M

Marina

I used iframes extensively in a particular project, and the page_load event
fired just fine. And here also, the src of the iframe was assigned at
runtime, not hard coded. Whether or not a page is loaded into an iframe
should not matter.

I think your problem lies elsewhere.

Try using a very simple page, that just does a response.write in the
page_load. Try posting your code here...
 
S

Stevie_mac

Thanks for your response, I did that & response.wrote now.ToString(). What
i've found is that the time was written the 1st time the aspx was shown but
always showed the same time in each following load (Probably something to do
with caching i guess?) Note: the aspx page is loaded by assignment (client
side) to the src property at run time - but within a .htm file - inside a
Modal dialog! Not sure how the page_load isnt called 2nd, 3rd time.

CODE...
*** Main.aspx (inside Page_Load)***
Button1.Attributes.Add("onclick", "var
strReturn=window.showModalDialog('popup.htm','popup.aspx?v1=" &
txtStartDate.Text & "','status:no;
dialogWidth:250px;dialogHeight:250px;dialogHide:true;help:no;scroll:no'); if
(strReturn) document.forms[0].txtStartDate.value=strReturn;")
Button2.Attributes.Add("onclick", "var
strReturn=window.showModalDialog('popup.htm','popup.aspx?v1=" &
txtEndDate.Text & "','status:no;
dialogWidth:250px;dialogHeight:250px;dialogHide:true;help:no;scroll:no'); if
(strReturn) document.forms[0].txtEndDate.value=strReturn;")


*** Popup.htm ***
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>popup</title>
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="ProgId" content="VisualStudio.HTML">
<meta name="Originator" content="Microsoft Visual Studio.NET 7.0">
<script language='javascript'>
//<!--
function load()
{
var src = window.dialogArguments;
if (src) {
document.all.Frame1.src = src;
}
}
//-->
</script>
</head>
<body onload='load()' MS_POSITIONING="GridLayout">
<iframe id="Frame1" height='100%' width='100%' style="OVERFLOW: auto;
BACKGROUND-COLOR: blue">
</iframe>
</body>
</html>

*** popup.aspx.vb ***
Imports System.Web.UI.HtmlControls.HtmlGenericControl
Public Class PopUp
Inherits System.Web.UI.Page
Protected WithEvents calDate As System.Web.UI.WebControls.Calendar
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If IsPostBack = False Then
If (Request.QueryString("v1") & "") <> "" Then
If Microsoft.VisualBasic.IsDate(Request.QueryString("v1").ToString()) Then
calDate.SelectedDate = CDate(Request.QueryString("v1").ToString())
calDate.VisibleDate = calDate.SelectedDate
End If
End If
End If
End Sub
Private Sub calDate_SelectionChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles calDate.SelectionChanged
AddClientScript()
End Sub
Private Sub AddClientScript()
Dim strScript As String = "<script>"
strScript &= "window.returnValue='" &
calDate.SelectedDate.ToString("dd-MMM-yyyy") & "';"
strScript &= "window.close()"
strScript &= "</" & "script>"
RegisterClientScriptBlock("anything", strScript)
End Sub
End Class

*** popup.aspx ***
<%@ Page Language="vb" AutoEventWireup="false" Src="PopUp.aspx.vb"
Inherits="PopUp" smartNavigation="True"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>PopUp</title>
<base target="_self">
<meta url="popup.aspx">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body onload="window.focus()" MS_POSITIONING="GridLayout">
<form id="Form1" method="post" target="_self" runat="server">
<asp:calendar id="calDate" Runat="server" BackColor="White" Width="100%"
DayNameFormat="FirstLetter" ForeColor="Black" Height="100%" Font-Size="8pt"
Font-Names="Verdana" BorderColor="#999999" CellPadding="4">
<TodayDayStyle ForeColor="Black" BackColor="#CCCCCC"></TodayDayStyle>
<SelectorStyle BackColor="#CCCCCC"></SelectorStyle>
<NextPrevStyle VerticalAlign="Bottom"></NextPrevStyle>
<DayHeaderStyle Font-Size="7pt" Font-Bold="True"
BackColor="#CCCCCC"></DayHeaderStyle>
<SelectedDayStyle Font-Bold="True" ForeColor="White"
BackColor="#666666"></SelectedDayStyle>
<TitleStyle Font-Bold="True" BorderColor="Black"
BackColor="#999999"></TitleStyle>
<WeekendDayStyle BackColor="#FFFFCC"></WeekendDayStyle>
<OtherMonthDayStyle ForeColor="#808080"></OtherMonthDayStyle>
</asp:calendar>
</form>
</body>
</HTML>
 
S

Stevie_mac

Cant believe i made a TYPO! DOH!
Button1.Attributes.Add("onclick", "var
strReturn=window.showModalDialog('popup.htm','popup.aspx?v1=' +
document.forms[0].txtStartDate.value ,'status:no;
dialogWidth:250px;dialogHeight:250px;dialogHide:true;help:no;scroll:no'); if
(strReturn) document.forms[0].txtStartDate.value=strReturn;")

Button2.Attributes.Add("onclick", "var
strReturn=window.showModalDialog('popup.htm','popup.aspx?v1=' +
document.forms[0].txtEndDate.value ,'status:no;
dialogWidth:250px;dialogHeight:250px;dialogHide:true;help:no;scroll:no'); if
(strReturn) document.forms[0].txtEndDate.value=strReturn;")

Stevie_mac said:
MAN! i've sussed it! the client script to start things off should read...
Button1.Attributes.Add("onclick", "var
strReturn=window.showModalDialog('popup.htm','popup.aspx?v1=' +
document.forms[0].txtStartDate.value ,'status:no;
dialogWidth:250px;dialogHeight:250px;dialogHide:true;help:no;scroll:no'); if
(strReturn) document.forms[0].txtStartDate.value=strReturn;")
Button2.Attributes.Add("onclick", "var
strReturn=window.showModalDialog('popup.htm','popup.aspx?v1=' +
document.forms[0].txtStartDate.value ,'status:no;
dialogWidth:250px;dialogHeight:250px;dialogHide:true;help:no;scroll:no'); if
(strReturn) document.forms[0].txtEndDate.value=strReturn;")

Now working fine. Still not sure how DEV environment was not stopping on
break point in Page_Load event in popup.aspx but - it works now. Thanks
again.
<-- SNIP -->
 

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,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top