469,946 Members | 1,901 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,946 developers. It's quick & easy.

Page_Load event not fired

Some pages (not all the pages, but I can't observe differences) opened from
javascript via window.showModalDialog() doesn't fire the codebehind
Page_Load event the second (and further) time it is opened from the same
window.

If I change the IE configuration of the temporary internet files to check
new versions every time the page is called then the event is fired. However
it is not an acceptable solution.

Thanks.

Alfons Puig
ap***@sisinf.com
Nov 18 '05 #1
4 3200
"Alfons Puig" <ap***@sisinf.com> wrote in message
news:u9**************@TK2MSFTNGP10.phx.gbl...
Some pages (not all the pages, but I can't observe differences) opened from javascript via window.showModalDialog() doesn't fire the codebehind
Page_Load event the second (and further) time it is opened from the same window.

If I change the IE configuration of the temporary internet files to check new versions every time the page is called then the event is fired. However it is not an acceptable solution.


From your server, send appropriate HTTP cache control headers, such as
Exprires: or Pragma: no-cache, to prevent the page from being cached.
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
Nov 18 '05 #2
Perhaps the pages are being cached?
To prevent caching use this code:

Response.Expires = 0
Response.Cache.SetNoStore()
Response.AppendHeader("Pragma", "no-cache")

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"Alfons Puig" <ap***@sisinf.com> wrote in message
news:u9**************@TK2MSFTNGP10.phx.gbl...
Some pages (not all the pages, but I can't observe differences) opened from javascript via window.showModalDialog() doesn't fire the codebehind
Page_Load event the second (and further) time it is opened from the same
window.

If I change the IE configuration of the temporary internet files to check
new versions every time the page is called then the event is fired. However it is not an acceptable solution.

Thanks.

Alfons Puig
ap***@sisinf.com

Nov 18 '05 #3
Hi Alfons,
Thanks for posting in the community! My name is Steven, and I'll be
assisting you on this issue.
From your description, when you loaded a page again(second time) using
"window.showModalDialog" javascript code, the page(be opened) seemed not be
newly loaded(page's server Load event was not fired)
However, when you change the IE's page "check for new version always" as
true, it worked, yes?
If there is anything I misunderstood, please feel free to let me know.
I've done some tests on my side and did encountered the same problem. I've
also tried Steve's suggestion that set the page's client cache attribute
via:
Response.Expires = 0;
Response.Cache.SetNoStore();
Response.AppendHeader("Pragma", "no-cache");

Yes, this did work. So the problem is due to the client cache. The page
popuped be the "showModalDialog" may be cached by default. You may also try
Steve's solution to see whether it works for you.
In addition, here is the test page I used to test Steve' suggestion, you
may have a look as reference if you have anything unclear:

------------------------------first page's aspx
file--------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>PopUp</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
var hNew

function PopUp()
{
var dt = new Date();
divMessage.innerText = dt.getMilliseconds();

hNew = window.showModalDialog("Refresh.aspx");
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="500" align="center">
<tr>
<td><div id="divMessage"></div>
</td>
</tr>
<tr>
<td><INPUT id="btnShow" type="button" value="ShowPage"
onclick="PopUp()"></td>
</tr>
</table>
</form>
</body>
</HTML>

---------------------------the poped up page's aspx page
file-------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Refresh</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<base target=_self>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="500" align="center">
<tr>
<td>
<asp:Label id="lblMessage" runat="server"></asp:Label>
</td>
<td>
<asp:Button ID="btnPost" Text="Post Back" Runat="server"></asp:Button>
</td>
</tr>
</table>
</form>
</body>
</HTML>
------------------------------the poped up page's code behind page
class----------------------
public class Refresh : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnPost;
protected System.Web.UI.WebControls.Label lblMessage;

private void Page_Load(object sender, System.EventArgs e)
{
lblMessage.Text = "Load at: " + DateTime.Now.ToLongTimeString();
Response.Expires = 0;
Response.Cache.SetNoStore();
Response.AppendHeader("Pragma", "no-cache");
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
Please check out the suggestion. If you have any further questions, please
feel free to post here.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4
Hi Alfons,
Have you had a chance to try out the suggestion in the last reply or have
you resolved this problem? If you need any assistance, please feel free to
post here.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Frank Schumacher | last post: by
14 posts views Thread by V. Jenks | last post: by
4 posts views Thread by Seraph | last post: by
1 post views Thread by Michal Kostic via .NET 247 | last post: by
1 post views Thread by Rippo | last post: by
12 posts views Thread by Nathan Sokalski | last post: by
3 posts views Thread by =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.