开发者

Page OnLoad not fireing changing query string

开发者 https://www.devze.com 2023-01-28 03:52 出处:网络
I have a problem that the OnLoad event is not fireing when I navigate to a page and just change the query string. If I do a postback it is called, then changing the querystring ones more OnLoad gets c

I have a problem that the OnLoad event is not fireing when I navigate to a page and just change the query string. If I do a postback it is called, then changing the query string ones more OnLoad gets called.

Here is how i try. I navigate to the page OnLoad fires -> then change the query string page updates (all bound elements get updated) OnLoad does not fire -> I do a postback using a button OnLoad fires -> then change the query string OnLoad fires.

I will try to explain in more detail.

The system has log in window when I log in I navigate to an other aspx page sending two query string messages the last query string is a number (page.aspx?key=text82&key2=2010). When I get to the page the first time PageLoad event gets called and all is fine, if I in the browser change the key2 to 2011 and press enter the PageLoad does not get called but all my bound elements get updated (GrivView etc..). If I then do a postback using a button the PageLoad gets called. If I now change the 2011 back to 2010 and press Enter PageLoad is called.

I tr开发者_运维知识库y this is firefox the PageLoad get called every time.

I tired to write a test website but I do not get the same problem, but what i found out is that in IE 8 changing the query string to the same number and pressing enter the PageLoad is not called. But doing so in firefox makes the postback fire. Here is the test code

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master"     AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
    Welcome to ASP.NET!
</h2>
<p>
    <asp:Button ID="Button1" runat="server" Text="Button" />
    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Default2.aspx?t=tt&   tttttt=2010">HyperLink</asp:HyperLink>
</p>
<p>
    You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409"
        title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
</p>
</asp:Content>

Navigates to

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.master" CodeFile="Default2.aspx.cs"
Inherits="Default2" %>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><asp:Button ID="Button1"
    runat="server" Text="Button" />
</asp:Content>

OnLoad event Default2.aspx

protected void Page_Load(object sender, EventArgs e)
{
    Label1.Text += "Called " + DateTime.Now.ToString();
}


I found out the problem. Looks like the browser cache was giving me the problem. Press F12 and cleared the cache, it works.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号