views:

612

answers:

8

Hi,

I've been thrown into an ASP.NET project and I've got a page which contains a control that is fetched via AJAX.

The Page_Load function of the control does a little bit of logic necessary to get the correct values from the Query string.

The problem is that the Page_Load function isn't called in IE.

If I put a breakpoint in, I can load the page in FF and watch it stop, but in IE: no deal.

I'm pretty (read: COMPLETELY) new to ASP.NET, but I'm a pretty experienced PHP developer. So I'm thinking it's probably some funk with the way that IE does the AJAX callback to get the control.

Has anyone got any ideas?

Cheers

A: 

i'd try to use the IE Developer Toolbar to help debug the IE problem but I think you are on the right track.

You can also enable script debugging in the Advanced Options of IE and debug the script.

Jeff Martin
Yeah, but the Dev tool bar don't let you debug JS does it?Oh for firebug on IE....
half_brick
no but it can help. In IE you could enable script debugging and attach the script debugger to your IE.
Jeff Martin
A: 

What is inside the Page_Load? Either EventWireup is set to false on the ASPX page, or it's something in the code.

BBetances
Hrm, EventWireup isn't specified, which from what I've read means it defaults to true. Is there anything prior to Page_Load that would invalidate it (for IE only)?The fact that it's IE only leads me to believe it's a client side issue...?
half_brick
+1  A: 

Maybe try debugging the javascript to see if it ever trys to get the control in IE? If you can. Better yet, watch in Fiddler. http://www.Fiddler2.com

benjynito
A: 

IE8 will let you debug the javascript. AFAIK, what you are explaining should not happen in a typical setup, because the server handles requests from all browsers the same. Are you sure you are sitting on the correct breakpoint, and on the correct page?

Perhaps you could post a small sample of the page_load and where you are setting the breakpoint, and the JS that calls back to it?

For your reference, here is the ASP.NET page lifecycle.

StingyJack
A: 

@StingyJack I'm pretty damn sure it's the correct place for the breakpoint, as in Firefox execution stops exactly where I place it. It's just that doing the same thing in IE doesn't cause the breakpoint to stop there (breakpoints still trigger elsewhere in IE).

Here's the top of the Page_Load function if it helps anything:

    protected void Page_Load(object sender, System.EventArgs e)
    {
        //
        // Test if the site is open for trading.
        //
//breakpoint next line >> 
        if (PolicyService.IsSiteClosed())
        {
            this.divOpen.Visible = false;
            this.tradingClosed.Visible = true;
        }

I've had a good read of the page lifecycle previously, I won't pretend to know it backwards and forwards yet, but I'm pretty sure my haziness on it isn't the root of the problem.

Cos surely if it happens in FF but not IE, and the server side code is the same it's gotta be something to do with the way IE posts back right!!

I'm gonna roll up my sleeves and try to get JS debugging on IE going.

half_brick
Yup. Thats the place. You said "COMPLETELY New", so I started at the beginning. Don't take offense. Try setting breakpoints on OnLoad(if available), PreInit, and Init to see if they hit those either.
StingyJack
Heh, yep complete ASP.NET n00bzor here, so no offense taken.I'll just keep plugging at it.Thanks for your help!
half_brick
A: 

Could my problem be related to cacheing somehow?

I've noticed that if the URL is the same as the previously requested URL then Page_Load is not called, but if one of the parameters changes, then Page_Load does get called.

It would have to be browser side cacheing, since FF doesn't behave in this way...

Thoughts?

half_brick
+1  A: 

It seems like it was a caching issue, solved by doing something like this:

protected override void OnLoad(EventArgs e)
{
    Response.Cache.SetNoStore();
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.Cache.SetExpires(DateTime.Now);
    Response.Cache.SetLastModified(DateTime.Now);
    Response.Cache.SetAllowResponseInBrowserHistory(false);
    base.OnLoad(e);
}
half_brick
+1  A: 

If it's the caching, you should turn it off by using the OutputCache directive:

<%@ OutputCache Duration="0" VaryByParam="None" %>
IainMH
This will cause a runtime error, as the Duration parameter cannot be set to 0. Setting it to 1 second should work in this case.
tomlog
Really? That's a bit weird.
IainMH